+ - * /As a Calculator
When you use the Python shell, your commands are executed as you write. It is hence possible to use the Python shell as a calculator.
Start IDLE to enter the Python shell.
The arithmetic operators in Python 3 are:
**//%Exercise 1
Calculate following expressions, only use brackets when you need it
>>> 4.2/(7.3+0.26)
0.5555555555555556>>> 4.2/7.3/0.26
2.212855637513172>>> 7.3*0.26/4.2
0.45190476190476186>>> 3*-5
-15>>> 200**0.5
14.142135623730951>>> 200**(5/7)
44.01420420561975
Exercise 2
How many hours and minutes are there in 500 minutes?
>>> 500//608>>> 500%6020Exercise 3
From the code
>>> 22//5 4 >>> 22%5 2
you can conclude that 22 = 5 · 4 + 2.
Make an educated guess of the result when typing -22//5 and
-22%5 in Python. Check your answer in IDLE.
>>> -22//5-5>>> -22%53Exercise 4
The operators * and / have higher precedence (they will be calculated first) than the operators
+ and -. What precedence does
the operator ** have? Find it out using IDLE by considering the fact that

>>> 2*9**1/29.0** has higher precedence, it is calculated first.
further info:
In 5.15 Summary there is a table of the operator precedences in Python: http://docs.python.org/reference/expressions.html
by Malin Christersson under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 Sweden License





