Python 3 Variable And Value. | pycoder

python3 Variable Assignment.

Think of a variable as a name attached to particular object. In python, Variables need not be declared or defined in advance, as is the case in many other programming languages. To create a variable, you just assign it a value and then start using it assignment is done with a single equals sign (=):

  python                                           

   >>> n = 3                                    

This is read or interpreted as "n is assigned value 30. " Once this is done, n can be used in a statement or expression, and its value will be substituted:

      python                                                    
>>> print (n)                                               
   3                                                                

Later, if change the value of n and use it again, the new value will be substituted instead:

  python                                              
 >>> n = 100                                     
 >>>print (n)                                     
 100                                                    




No comments:

Powered by Blogger.