Turtle Graphics
Assignment Statements in Python
Statements such as
size = 100
size = size + 2 * spacing
are called assignment statements.
The right hand side of the size = size + 2 * spacing
statement is a mathematical expression.
Assignment statements are also valid for text variables
courseName = "Boun102”
courseName = "Boun" + "102"
where the right hand side of the latter is not a mathematical expression, but a string concatenation.
The left hand side of both assignment statements are called variables, named size and courseName respectively.
In python, multiple variables can be assigned in a single assignment statement
a, b = 100, 450
print("a :", a)
print("b :", b)
c, d, e = 200, 250, 300
print("c :", c)
print("d :", d)
print("e :", e)
f, g = a, d
print("f :", f)
print("g :", g)
a, d = 50, 60
print("a :", a)
print("d :", d)
print("f :", f)
print("g :", g)
The values of two variables can be swapped easily in Python without the need for a third variable
a, b = 100, 450
print("a :", a)
print("b :", b)
a, b = b, a
print("a :", a)
print("b :", b)