Assigning variables

Since a variable is just a description of the underlying data, the data can change. For example, if you have a variable named time, you would expect its value to change every second. At any point, you can use the assignment operator = to assign a new value to a variable.

This code snippet explores this by creating a single variable, color, and assigning it three different values. The value of color is printed after each assignment:

color = "red"
print (color)
color = "green"
print (color)
color = "blue"
print (color)

The output from this program should look like this:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.162.37