## Calculations

You can perform calculations on numbers in Python using the four main operators:

For **addition** we use the **plus sign.**

To **subtract** numbers we use the dash symbol **–** (**Not** an underscore _ )

For **multiplication** we use an **asterisk *** which can be made by pressing Shift and 8 on a typical keyboard.

To **divide** numbers we use a **forward slash /** (**Not** a backslash \ )

We don’t have to just calculate with numbers like 89 or 47, we can perform calculations on variables that we have assigned ourselves or variables that have been inputted:

If you look at the above example we can’t just perform a calculation (like number1 + number2) and expect it to save the answer. That is why we have used number3 – it is a variable that saves the answer to number1 plus number2.

Practice Task 1

1. The easiest way to directly perform a calculation is by writing it inside print brackets. For example:

print(84/7)

Write 4 print lines, each with a different calculation operator (+ – * /)

2. Create a variable called number1 with the value of 8.

Write a print statement to print number1 multiplied by 9.

## Calculations not working? Tick off these common errors:

Have you saved a calculation into a variable?

You can’t just calculate values and expect Python to save it automatically. You need a variable to save it into:

total = number1 * number2

Correct calculation symbols?

A common error is to use x instead of * to multiply and to use / instead of \ to divide.

price = 60 * 100

number3 = number1 / number2

Have you printed the calculation?

Don’t forget to print your new total variable!

total = 89+897

print(total)