December 2000
Intermediate to advanced
816 pages
16h 57m
English
This section focuses on variable assignment. We will discuss which identifiers make valid variables coming up in Section 3.3.
The equal sign ( = ) is the main Python assignment operator
anInt = -12 String = 'cart' aFloat = -3.1415 * (5.0 ** 2) anotherString = 'shop' + 'ping' aList = [ 3.14e10, '2nd elmt of a list', 8.82-4.371j ]
Be aware now that assignment does not explicitly assign a value to a variable, although it may appear that way from your experience with other programming languages. In Python, objects are referenced, so on assignment, a reference (not a value) to an object is what is being assigned, whether the object was just created or was a pre-existing object. ...
Read now
Unlock full access