Variables in Python
Declaring a variable in python is as easy as
writing code in simple english language. You
can use an assignment operator to directly
assign a value to any variable, although there
are certain rules that must be followed in
order to declare variables in Python.
variable_name = value
a = 10.
a = variable_name
10 = value.
We can Declare multiple variables in a single line of code in python as well.
a,b,c = 1,2,3
1 2 3
- Variables in Python are case sensitive.
- A variable name cannot start with a number.
- A variable name can consist of alphanumeric characters.
- A variable name can start with a character or an underscore.
Global Variables in Python :-
Global variables are those that can be used outside the scope of a class, function, etc. To create a global variable inside a function, you can use the global keyword as well.