Getting started 3. Three ways to run code
Three ways to run code
Python can work like a simple calculator.
>>> 1 + 5 * 2 - 3
8
>>> (2 + 3) * 4
20
>>> 1.0 / 3.0
0.3333333333333333
You can run Python code in three common ways.
1. Interactive terminal
$ python3
>>> 1 + 5 * 2 - 3
8
2. Script file
# calculator.py
print(1 + 5 * 2 - 3)
$ python3 calculator.py
3. IDE or notebook
- A VS Code Python file with the built-in terminal or Python extension
- A Colab notebook cell