top of page
Writer's pictureRajesh Singh

Python Variables

Updated: May 18, 2020


Variables are used to store data and take memory space based on the type of value we assigning to them. We create variables in Python is simple, we write the variable name on the left side of = and the value on the right side. We do not have to openly mention the type of the variable, python gather the type based on the value we are assigning. There are some rules for creating variables in Python.


  • The name of the variable must always start with either a letter or an underscore (_).

  • The name of the variable cannot start with a number like 2num is not a valid variable name.

  • The name of the variable cannot have special characters such as %, $, # etc, they can only have alphanumeric characters and underscore (A to Z, a to z, 0-9 or _ ).

  • Variable name is case sensitive in Python which means num and NUM are two different variables in python.


Python Variable Example

num = 100

str = "Rajesh"

print (num)

print (str)


Output:

100

Rajesh



15 views0 comments

Recent Posts

See All

Comments


bottom of page