...

/

Assignment Statements

Assignment Statements

Learn about assignment statements in Python.

We'll cover the following...

Syntax

Assignment statements consist of a variable, an equal sign, and an expression.

Here’s an example:

Press + to interact
x = 1 # Assigning the value 1 to a variable x
print("x:", x)
y = 5 # Assigning the value 5 to a variable y
print("y:", y)
z = x + y # Assigning the value of the addition between x and y to z
print("z:", z)

Assignment shortcuts

You can also use shortcuts when ...