December 2000
Intermediate to advanced
816 pages
16h 57m
English
Rules for variables in Python are the same as they are in most other high-level languages: They are simply identifier names with an alphabetic first character—“alphabetic” meaning upper- or lowercase letters, including the underscore ( _ ). Any additional characters may be alphanumeric or underscore. Python is case-sensitive, meaning that the identifier “cAsE” is different from “CaSe.”
Python is dynamically-typed, meaning that no pre-declaration of a variable or its type is necessary. The type (and value) are initialized on assignment. Assignments are performed using the equals sign.
>>> counter = 0
>>> miles = 1000.0
>>> name = 'Bob'
>>> counter = counter + 1
>>> kilometers = 1.609 * miles
>>> print '%f miles ...Read now
Unlock full access