Python Variables for beginner by ShadBox

Total Blog Views: 37

Blog Status: publish

Created By: swazahmad Created at: 07-14-2021

Tags:

Variables 

 
variables are used to refer memory location. memory is used to hold the values. In python we don't need to specify the types of variables because python is a type infer language and smart to get variable type.

 

variable names can be  a group of digit and alphabet ,but they have to begin with a letter or an underscore. 

 

 
  • the first character of variable  must be an alphabet or underscore.
  • variables not contain any white-space (space) or special character (! , @ , # , $ , % , etc)

 Declaration Variable and Assigning Values  

we don't need to declare explicitly variable in python. when we assign any value to variable that variable is declare automatically.  

Example : 

 

 >>> a =100
    >>> print(a)
    100
    >>> a= 'ProgGeek'
    >>> print(a)
    ProgGeek
    >>> 
 
 

Multiple Assignment 

Python allows to assign multiple variable in single statement.
 

Examples :

 
  • Assign single value in multiple variables
     
>>> a=b=c=100
     >>> print(a,b,c)
     100 100 100
     >>> 
 
 
  • Assign multiple values in multiple variables
 
     >>> a=b=c=100,200,300
     >>> print(a,b,c)
     100 200 300
     >>> 


swazahmad

Swaz is Practice Lead of ROR Developer. he's a Blogger, Mentor, and Rubyst. He has expertise in Javascript also . he's highly skilled in designing, developing and testing web applications. He enjoys being challenged and interesting with projects that need him to



Comments



  • swazahmad | almost 4 years ago
    Awesome Information Thanks For Sharing
Buy traffic for your website

About Shadbox

we have the “Get things executed” lifestyle at our place of work. There are not any excuses, no if’s or however’s in our dictionary. committed to navigating the ship of creativity to create cell answers, we resolve the real-lifestyles troubles of our clients and their clients. Our passion for work has won us many awards, year after 12 months.

Services

Downloads