1596918300
What is a surveillance state? Privacy International defines it as one which _“collects information on everyone without regard to innocence or guilt” _and “deputizes the private sector by compelling access to their data”.
While this may sound dystopian, this is quickly becoming a reality right here in the United States with serious implications on our civil liberties.
Despite its portrayal as the global poster child for surveillance, China is actually on par with the USA in regard to security cameras per capita; based on data from IHS Markit, there is currently one security camera per every 4.6 and 4.1 people in the USA and China, respectively.
While China’s security camera network is primarily government-owned, the majority of security cameras in the USA are consumer-owned. Interestingly, the rapid installation of over 85 million security cameras in the USA has been fueled by partnerships between the public and private sectors, namely police agencies and data-hungry tech giants.
The proliferation of security cameras in the USA is fueled by public-private partnerships between police and Big Tech.
The most striking example of this is Amazon’s Ring, whose aggressive nationwide expansion is fueled by 900+ partnerships with police agencies in 44 states. As part of these partnerships, police actively support the installation of Ring cameras via taxpayer-funded discount programs; in exchange, they gain access to Ring’s Neighborhood Watch Portal, a tool that allows police to request video footage directly from Ring users without a warrant.
For example, in Baltimore police are offering homeowners up to $150 rebates to cover camera and installation costs. The catch? They must share all of their video footage with police for at least two years. With police and Big Tech in control of our security camera infrastructure, new threats to our civil liberties are now just a “flip of a switch” away.
#cryptocurrency #privacy #data #iot #surveillance #data analysis
1652496780
In this article, you will learn the basics of global variables.
To begin with, you will learn how to declare variables in Python and what the term 'variable scope' actually means.
Then, you will learn the differences between local and global variables and understand how to define global variables and how to use the global
keyword.
You can think of variables as storage containers.
They are storage containers for holding data, information, and values that you would like to save in the computer's memory. You can then reference or even manipulate them at some point throughout the life of the program.
A variable has a symbolic name, and you can think of that name as the label on the storage container that acts as its identifier.
The variable name will be a reference and pointer to the data stored inside it. So, there is no need to remember the details of your data and information – you only need to reference the variable name that holds that data and information.
When giving a variable a name, make sure that it is descriptive of the data it holds. Variable names need to be clear and easily understandable both for your future self and the other developers you may be working with.
Now, let's see how to actually create a variable in Python.
When declaring variables in Python, you don't need to specify their data type.
For example, in the C programming language, you have to mention explicitly the type of data the variable will hold.
So, if you wanted to store your age which is an integer, or int
type, this is what you would have to do in C:
#include <stdio.h>
int main(void)
{
int age = 28;
// 'int' is the data type
// 'age' is the name
// 'age' is capable of holding integer values
// positive/negative whole numbers or 0
// '=' is the assignment operator
// '28' is the value
}
However, this is how you would write the above in Python:
age = 28
#'age' is the variable name, or identifier
# '=' is the assignment operator
#'28' is the value assigned to the variable, so '28' is the value of 'age'
The variable name is always on the left-hand side, and the value you want to assign goes on the right-hand side after the assignment operator.
Keep in mind that you can change the values of variables throughout the life of a program:
my_age = 28
print(f"My age in 2022 is {my_age}.")
my_age = 29
print(f"My age in 2023 will be {my_age}.")
#output
#My age in 2022 is 28.
#My age in 2023 will be 29.
You keep the same variable name, my_age
, but only change the value from 28
to 29
.
Variable scope refers to the parts and boundaries of a Python program where a variable is available, accessible, and visible.
There are four types of scope for Python variables, which are also known as the LEGB rule:
For the rest of this article, you will focus on learning about creating variables with global scope, and you will understand the difference between the local and global variable scopes.
Variables defined inside a function's body have local scope, which means they are accessible only within that particular function. In other words, they are 'local' to that function.
You can only access a local variable by calling the function.
def learn_to_code():
#create local variable
coding_website = "freeCodeCamp"
print(f"The best place to learn to code is with {coding_website}!")
#call function
learn_to_code()
#output
#The best place to learn to code is with freeCodeCamp!
Look at what happens when I try to access that variable with a local scope from outside the function's body:
def learn_to_code():
#create local variable
coding_website = "freeCodeCamp"
print(f"The best place to learn to code is with {coding_website}!")
#try to print local variable 'coding_website' from outside the function
print(coding_website)
#output
#NameError: name 'coding_website' is not defined
It raises a NameError
because it is not 'visible' in the rest of the program. It is only 'visible' within the function where it was defined.
When you define a variable outside a function, like at the top of the file, it has a global scope and it is known as a global variable.
A global variable is accessed from anywhere in the program.
You can use it inside a function's body, as well as access it from outside a function:
#create a global variable
coding_website = "freeCodeCamp"
def learn_to_code():
#access the variable 'coding_website' inside the function
print(f"The best place to learn to code is with {coding_website}!")
#call the function
learn_to_code()
#access the variable 'coding_website' from outside the function
print(coding_website)
#output
#The best place to learn to code is with freeCodeCamp!
#freeCodeCamp
What happens when there is a global and local variable, and they both have the same name?
#global variable
city = "Athens"
def travel_plans():
#local variable with the same name as the global variable
city = "London"
print(f"I want to visit {city} next year!")
#call function - this will output the value of local variable
travel_plans()
#reference global variable - this will output the value of global variable
print(f"I want to visit {city} next year!")
#output
#I want to visit London next year!
#I want to visit Athens next year!
In the example above, maybe you were not expecting that specific output.
Maybe you thought that the value of city
would change when I assigned it a different value inside the function.
Maybe you expected that when I referenced the global variable with the line print(f" I want to visit {city} next year!")
, the output would be #I want to visit London next year!
instead of #I want to visit Athens next year!
.
However, when the function was called, it printed the value of the local variable.
Then, when I referenced the global variable outside the function, the value assigned to the global variable was printed.
They didn't interfere with one another.
That said, using the same variable name for global and local variables is not considered a best practice. Make sure that your variables don't have the same name, as you may get some confusing results when you run your program.
global
Keyword in PythonWhat if you have a global variable but want to change its value inside a function?
Look at what happens when I try to do that:
#global variable
city = "Athens"
def travel_plans():
#First, this is like when I tried to access the global variable defined outside the function.
# This works fine on its own, as you saw earlier on.
print(f"I want to visit {city} next year!")
#However, when I then try to re-assign a different value to the global variable 'city' from inside the function,
#after trying to print it,
#it will throw an error
city = "London"
print(f"I want to visit {city} next year!")
#call function
travel_plans()
#output
#UnboundLocalError: local variable 'city' referenced before assignment
By default Python thinks you want to use a local variable inside a function.
So, when I first try to print the value of the variable and then re-assign a value to the variable I am trying to access, Python gets confused.
The way to change the value of a global variable inside a function is by using the global
keyword:
#global variable
city = "Athens"
#print value of global variable
print(f"I want to visit {city} next year!")
def travel_plans():
global city
#print initial value of global variable
print(f"I want to visit {city} next year!")
#assign a different value to global variable from within function
city = "London"
#print new value
print(f"I want to visit {city} next year!")
#call function
travel_plans()
#print value of global variable
print(f"I want to visit {city} next year!")
Use the global
keyword before referencing it in the function, as you will get the following error: SyntaxError: name 'city' is used prior to global declaration
.
Earlier, you saw that you couldn't access variables created inside functions since they have local scope.
The global
keyword changes the visibility of variables declared inside functions.
def learn_to_code():
global coding_website
coding_website = "freeCodeCamp"
print(f"The best place to learn to code is with {coding_website}!")
#call function
learn_to_code()
#access variable from within the function
print(coding_website)
#output
#The best place to learn to code is with freeCodeCamp!
#freeCodeCamp
And there you have it! You now know the basics of global variables in Python and can tell the differences between local and global variables.
I hope you found this article useful.
You'll start from the basics and learn in an interactive and beginner-friendly way. You'll also build five projects at the end to put into practice and help reinforce what you've learned.
Thanks for reading and happy coding!
Source: https://www.freecodecamp.org/news/python-global-variables-examples/
1597487472
Here, i will show you how to populate country state city in dropdown list in php mysql using ajax.
You can use the below given steps to retrieve and display country, state and city in dropdown list in PHP MySQL database using jQuery ajax onchange:
https://www.tutsmake.com/country-state-city-database-in-mysql-php-ajax/
#country state city drop down list in php mysql #country state city database in mysql php #country state city drop down list using ajax in php #country state city drop down list using ajax in php demo #country state city drop down list using ajax php example #country state city drop down list in php mysql ajax
1652450400
En este artículo, aprenderá los conceptos básicos de las variables globales.
Para empezar, aprenderá cómo declarar variables en Python y qué significa realmente el término 'ámbito de variable'.
Luego, aprenderá las diferencias entre variables locales y globales y comprenderá cómo definir variables globales y cómo usar la global
palabra clave.
Puede pensar en las variables como contenedores de almacenamiento .
Son contenedores de almacenamiento para almacenar datos, información y valores que le gustaría guardar en la memoria de la computadora. Luego puede hacer referencia a ellos o incluso manipularlos en algún momento a lo largo de la vida del programa.
Una variable tiene un nombre simbólico y puede pensar en ese nombre como la etiqueta en el contenedor de almacenamiento que actúa como su identificador.
El nombre de la variable será una referencia y un puntero a los datos almacenados en su interior. Por lo tanto, no es necesario recordar los detalles de sus datos e información; solo necesita hacer referencia al nombre de la variable que contiene esos datos e información.
Al dar un nombre a una variable, asegúrese de que sea descriptivo de los datos que contiene. Los nombres de las variables deben ser claros y fácilmente comprensibles tanto para usted en el futuro como para los otros desarrolladores con los que puede estar trabajando.
Ahora, veamos cómo crear una variable en Python.
Al declarar variables en Python, no necesita especificar su tipo de datos.
Por ejemplo, en el lenguaje de programación C, debe mencionar explícitamente el tipo de datos que contendrá la variable.
Entonces, si quisiera almacenar su edad, que es un número entero, o int
tipo, esto es lo que tendría que hacer en C:
#include <stdio.h>
int main(void)
{
int age = 28;
// 'int' is the data type
// 'age' is the name
// 'age' is capable of holding integer values
// positive/negative whole numbers or 0
// '=' is the assignment operator
// '28' is the value
}
Sin embargo, así es como escribirías lo anterior en Python:
age = 28
#'age' is the variable name, or identifier
# '=' is the assignment operator
#'28' is the value assigned to the variable, so '28' is the value of 'age'
El nombre de la variable siempre está en el lado izquierdo y el valor que desea asignar va en el lado derecho después del operador de asignación.
Tenga en cuenta que puede cambiar los valores de las variables a lo largo de la vida de un programa:
my_age = 28
print(f"My age in 2022 is {my_age}.")
my_age = 29
print(f"My age in 2023 will be {my_age}.")
#output
#My age in 2022 is 28.
#My age in 2023 will be 29.
Mantienes el mismo nombre de variable my_age
, pero solo cambias el valor de 28
a 29
.
El alcance de la variable se refiere a las partes y los límites de un programa de Python donde una variable está disponible, accesible y visible.
Hay cuatro tipos de alcance para las variables de Python, que también se conocen como la regla LEGB :
En el resto de este artículo, se centrará en aprender a crear variables con alcance global y comprenderá la diferencia entre los alcances de variables locales y globales.
Las variables definidas dentro del cuerpo de una función tienen alcance local , lo que significa que solo se puede acceder a ellas dentro de esa función en particular. En otras palabras, son 'locales' para esa función.
Solo puede acceder a una variable local llamando a la función.
def learn_to_code():
#create local variable
coding_website = "freeCodeCamp"
print(f"The best place to learn to code is with {coding_website}!")
#call function
learn_to_code()
#output
#The best place to learn to code is with freeCodeCamp!
Mire lo que sucede cuando trato de acceder a esa variable con un alcance local desde fuera del cuerpo de la función:
def learn_to_code():
#create local variable
coding_website = "freeCodeCamp"
print(f"The best place to learn to code is with {coding_website}!")
#try to print local variable 'coding_website' from outside the function
print(coding_website)
#output
#NameError: name 'coding_website' is not defined
Plantea un NameError
porque no es 'visible' en el resto del programa. Solo es 'visible' dentro de la función donde se definió.
Cuando define una variable fuera de una función, como en la parte superior del archivo, tiene un alcance global y se conoce como variable global.
Se accede a una variable global desde cualquier parte del programa.
Puede usarlo dentro del cuerpo de una función, así como acceder desde fuera de una función:
#create a global variable
coding_website = "freeCodeCamp"
def learn_to_code():
#access the variable 'coding_website' inside the function
print(f"The best place to learn to code is with {coding_website}!")
#call the function
learn_to_code()
#access the variable 'coding_website' from outside the function
print(coding_website)
#output
#The best place to learn to code is with freeCodeCamp!
#freeCodeCamp
¿Qué sucede cuando hay una variable global y local, y ambas tienen el mismo nombre?
#global variable
city = "Athens"
def travel_plans():
#local variable with the same name as the global variable
city = "London"
print(f"I want to visit {city} next year!")
#call function - this will output the value of local variable
travel_plans()
#reference global variable - this will output the value of global variable
print(f"I want to visit {city} next year!")
#output
#I want to visit London next year!
#I want to visit Athens next year!
En el ejemplo anterior, tal vez no esperaba ese resultado específico.
Tal vez pensaste que el valor de city
cambiaría cuando le asignara un valor diferente dentro de la función.
Tal vez esperabas que cuando hice referencia a la variable global con la línea print(f" I want to visit {city} next year!")
, la salida sería en #I want to visit London next year!
lugar de #I want to visit Athens next year!
.
Sin embargo, cuando se llamó a la función, imprimió el valor de la variable local.
Luego, cuando hice referencia a la variable global fuera de la función, se imprimió el valor asignado a la variable global.
No interfirieron entre sí.
Dicho esto, usar el mismo nombre de variable para variables globales y locales no se considera una buena práctica. Asegúrese de que sus variables no tengan el mismo nombre, ya que puede obtener algunos resultados confusos cuando ejecute su programa.
global
palabra clave en Python¿Qué sucede si tiene una variable global pero desea cambiar su valor dentro de una función?
Mira lo que sucede cuando trato de hacer eso:
#global variable
city = "Athens"
def travel_plans():
#First, this is like when I tried to access the global variable defined outside the function.
# This works fine on its own, as you saw earlier on.
print(f"I want to visit {city} next year!")
#However, when I then try to re-assign a different value to the global variable 'city' from inside the function,
#after trying to print it,
#it will throw an error
city = "London"
print(f"I want to visit {city} next year!")
#call function
travel_plans()
#output
#UnboundLocalError: local variable 'city' referenced before assignment
Por defecto, Python piensa que quieres usar una variable local dentro de una función.
Entonces, cuando intento imprimir el valor de la variable por primera vez y luego reasignar un valor a la variable a la que intento acceder, Python se confunde.
La forma de cambiar el valor de una variable global dentro de una función es usando la global
palabra clave:
#global variable
city = "Athens"
#print value of global variable
print(f"I want to visit {city} next year!")
def travel_plans():
global city
#print initial value of global variable
print(f"I want to visit {city} next year!")
#assign a different value to global variable from within function
city = "London"
#print new value
print(f"I want to visit {city} next year!")
#call function
travel_plans()
#print value of global variable
print(f"I want to visit {city} next year!")
Utilice la global
palabra clave antes de hacer referencia a ella en la función, ya que obtendrá el siguiente error: SyntaxError: name 'city' is used prior to global declaration
.
Anteriormente, vio que no podía acceder a las variables creadas dentro de las funciones ya que tienen un alcance local.
La global
palabra clave cambia la visibilidad de las variables declaradas dentro de las funciones.
def learn_to_code():
global coding_website
coding_website = "freeCodeCamp"
print(f"The best place to learn to code is with {coding_website}!")
#call function
learn_to_code()
#access variable from within the function
print(coding_website)
#output
#The best place to learn to code is with freeCodeCamp!
#freeCodeCamp
¡Y ahí lo tienes! Ahora conoce los conceptos básicos de las variables globales en Python y puede distinguir las diferencias entre las variables locales y globales.
Espero que hayas encontrado útil este artículo.
Comenzará desde lo básico y aprenderá de una manera interactiva y amigable para principiantes. También construirá cinco proyectos al final para poner en práctica y ayudar a reforzar lo que ha aprendido.
¡Gracias por leer y feliz codificación!
Fuente: https://www.freecodecamp.org/news/python-global-variables-examples/
1596918300
What is a surveillance state? Privacy International defines it as one which _“collects information on everyone without regard to innocence or guilt” _and “deputizes the private sector by compelling access to their data”.
While this may sound dystopian, this is quickly becoming a reality right here in the United States with serious implications on our civil liberties.
Despite its portrayal as the global poster child for surveillance, China is actually on par with the USA in regard to security cameras per capita; based on data from IHS Markit, there is currently one security camera per every 4.6 and 4.1 people in the USA and China, respectively.
While China’s security camera network is primarily government-owned, the majority of security cameras in the USA are consumer-owned. Interestingly, the rapid installation of over 85 million security cameras in the USA has been fueled by partnerships between the public and private sectors, namely police agencies and data-hungry tech giants.
The proliferation of security cameras in the USA is fueled by public-private partnerships between police and Big Tech.
The most striking example of this is Amazon’s Ring, whose aggressive nationwide expansion is fueled by 900+ partnerships with police agencies in 44 states. As part of these partnerships, police actively support the installation of Ring cameras via taxpayer-funded discount programs; in exchange, they gain access to Ring’s Neighborhood Watch Portal, a tool that allows police to request video footage directly from Ring users without a warrant.
For example, in Baltimore police are offering homeowners up to $150 rebates to cover camera and installation costs. The catch? They must share all of their video footage with police for at least two years. With police and Big Tech in control of our security camera infrastructure, new threats to our civil liberties are now just a “flip of a switch” away.
#cryptocurrency #privacy #data #iot #surveillance #data analysis
1597487833
Here, i will show you how to create dynamic depedent country state city dropdown list using ajax in laravel.
Follow Below given steps to create dynamic dependent country state city dropdown list with jQuery ajax in laravel:
https://www.tutsmake.com/ajax-country-state-city-dropdown-in-laravel/
#how to create dynamic dropdown list using laravel dynamic select box in laravel #laravel-country state city package #laravel country state city drop down #dynamic dropdown country city state list in laravel using ajax #country state city dropdown list using ajax in php laravel #country state city dropdown list using ajax in laravel demo