Calculations

Calculations

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

calc1For addition we use the plus sign.


calc2To subtract numbers we use the dash symbol  (Not an underscore _ )


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


calc4To 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:

calc5

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

Calculations not working? Tick off these common errors:

Have you saved a calculation into a variable?
Correct calculation symbols?
Have you printed the calculation?

< Back to Section Three