Now that we know how to store and change the value of variables let's do some math! Here are examples of common mathematical operators using Python syntax.

Addition

my_sum = a + b

Subtraction

my_difference = x - y

Multiplication

my_product = c * d

Division

my_quotient = a / b

Order of Operations

Parentheses can be used to order math operations:

first = 5
second = 7
third = 9
average_value = (first + second + third) / 3
print(average_value)

Which prints 7, the average of 5, 7, and 9.

Negative Numbers

Negative numbers in Python work the way you probably expect. Just add a minus sign:

my_negative_num = -420

Source: boot.dev