Variables
A variable is a name bound to an object; assigning again simply re-binds the name.
Beginner
current = 0.02 # binds the name to a float object
current = "20 mA" # now bound to a str — Python is dynamically typed
a = b = 0 # chained assignment
x, y = 3, 4 # unpacking
x, y = y, x # swap without a temporary
Variables don't have types; objects do. type(current) tells you the type of the object the name currently refers to.
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.