Python Core



Admission Enquiry Form




What is Variable?

Variable is a name given to the memory location which is used to store the value.

Python interpreter allocates memory according to the data type of the variable and decides what can be stored in the reserved memory. Therefore, by assigning different data types to Python variables, we can store integers, decimals or characters in the variables.




Creating Python Variables

num = 100 # Creates an integer variable

radius=10.25 # Creates a floating point variable

name="Compuhelp" # Creates a string variable




Printing Python Variables

num = 100 # Creates an integer variable

radius=10.25 # Creates a floating point variable

name="Compuhelp" # Creates a string variable

print(num)

print(radius)

print(name)




Rules to Declare Python Variables

  1. Variable name should be descriptive(meaningful).
  2. We must not use space in variable name.
  3. A variable name must start with a letter or the underscore character.
  4. A variable name cannot start with a number or any special character like @,$, (, * % etc.
  5. Python reserved keywords cannot be used for naming the variable.
  6. Python variable names are case-sensitive which means Fee and FEE are two different variables in Python.