-
Notifications
You must be signed in to change notification settings - Fork 2
Python Variables
Having objects isn't useful unless there is a way to use them. In order to use an object, there must be a way to reference them. In Python this is done by binding objects to names. A detailed overview of can be found here
One way this is done is by using an assignment statement. This is commonly called assigning a variable in the context of Python. If speaking about programming in the context of other languages, binding an object to a name may be more precise.
>>> some_number = 1
>>> print(some_number)
1
In the example above, the target of the assignment statement is a name (identifier), some_number
. The object being assigned is the number 1. The statement binds the object to the name. The second statement, we use this binding print
the object that some_number
refers to.
The identifier is not preceeded by a type. That is because Python is dynamically-typed language. The identifier is bound to an object that does have a type, however, the identifier itself can be rebound to another object of a different type:
>>> some_variable = 1
>>> print(some_variable)
1
>>> some_variable = "Hello campers!"
>>> print(some_variable)
Hello campers!
Learn to code and help nonprofits. Join our open source community in 15 seconds at http://freecodecamp.com
Follow our Medium blog
Follow Quincy on Quora
Follow us on Twitter
Like us on Facebook
And be sure to click the "Star" button in the upper right of this page.
New to Free Code Camp?
JS Concepts
JS Language Reference
- arguments
- Array.prototype.filter
- Array.prototype.indexOf
- Array.prototype.map
- Array.prototype.pop
- Array.prototype.push
- Array.prototype.shift
- Array.prototype.slice
- Array.prototype.some
- Array.prototype.toString
- Boolean
- for loop
- for..in loop
- for..of loop
- String.prototype.split
- String.prototype.toLowerCase
- String.prototype.toUpperCase
- undefined
Other Links