OK — it’s time for action! We’ll start our journey in something called the Python REPL. It’s an interactive shell that allows you to enter Python commands and directly see the results. It’s a great way to tinker and learn! We’ll use the REPL as a calculator and explore Python’s operators.
With your terminal open and the Python interactive shell started, you’ll see a command prompt consisting of three arrows (
>>>). Just to be absolutely clear, in the examples that follow you don’t type in the three arrows, only what follows after it.
Now type in the number 10, or any other number that you like:
>>> 10 10
What happened? Remember we are in a REPL, which is short for Read-Evaluate-Print-Loop:
Let’s give it something more challenging:
>>> 10 + 10 20
This time, Python recognized two numbers and a so-called operator, the plus sign, and evaluates this to 20. Yup, Python can be used as a calculator. In the next topic, you’ll learn to use Python as a calculator, by leveraging several operators.