Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> x= 20
>>>
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> x= 20
>>> print x+50
70
>>>
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> x= 20
>>> print x+50
70
>>> print x ** 3
8000
>>>
From the above example we can see how to assign single variable for a value which we can use it later in our code.
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> x= 20
>>> print x+50
70
>>> print x ** 3
8000
>>> y = 10
>>> print x+y
30
>>>
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> x= input("Enter the first value")
Enter the first value 10
>>> print x
10
>>>
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> x= input("Enter the first value")
Enter the first value 10
>>> print x
10
>>> y =input("Enter the second value")
Enter the second value 20
>>> print x+y
30
>>>
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (7)
Author
Commented:It is based on the data type of a value that we need or planing to assign it.
Let me know if anything else I need to change....
Commented:
Author
Commented:Author
Commented:But space I still agree.
Commented:
Assigning the above mentioned object with say 1 kB foot print means that say few bytes more are allocated -- much less than the object size. The object is not copied. It is only shared via the variable. The variable can immediately be assigned another object. If the other object already existed, no extra memory is allocated in the case.
View More