Python Language / Python Variables

It is a name used to store a value and no need declare the variables for its types in python.

Initialization of variables
Giving value to variables is called Initialization of variables.

Example
x = 9
y = "wisdom materials"

Rules for Python variables
1. It must start with a letter or the underscore character.
2. Its name cannot start with a number.
3. Its name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _).
4. Variable names are case-sensitive (age, Age and AGE are three different variables).

Output Variables
Python print statement is used to output variables.To combine text and a variable it uses the + character.

Sample Program Output

x = 9
y =”Wisdom Materials"
print(x)
print(y)

9
Wisdom Materials


Types of Python Numbers
1. int.
2. Float.
3. Complex.

Variables of numeric types are created when you assign a value to them.

Sample Program Output

x = 1 # int
y = 2.8 # float
z = 1+ 1j # complex
print(type(x))
print(type(y))
print(type(z))

<class 'int'>
<class 'float'>
<class 'complex'>




Home     Back