1. Start a Python interpreter and use it as a Calculator.
1. Starting the Python Interpreter
You can start Python in interactive mode (REPL) by typing one of the following in your
terminal:
python
or
python3
You should see something like:
Python 3.x.x (default, …)
>>>
The >>> prompt means Python is ready for commands.
2. Basic Arithmetic
Python supports normal math operations:
Operation Example Result
Addition >>> 2 + 3 5
Subtraction >>> 10 - 4 6
Multiplication >>> 7 * 8 56
Division >>> 10 / 4 2.5
Integer division >>> 10 // 4 2
Remainder >>> 10 % 4 2
Power >>> 2 ** 5 32
3. Using Math Functions
Import the math module:
>>> import math
Examples:
>>> [Link](2)
1.4142135623730951
>>> [Link](1)
0.8414709848078965
>>> [Link]
3.141592653589793
4. Using Variables
You can store results:
>>> x = 10
>>> y = 3
>>> x * y
30
5. Exiting the Interpreter
You can leave Python by typing:
>>> exit()
or pressing:
CTRL + D (Linux/Mac)
CTRL + Z then Enter (Windows)