Exploring The Python REPL
Today We have many IDEs and Many Python program running applications developed and known for ease of use and diverse features. But Working in the terminal is what it is preferred and it is considered as an effective way to learn as a coder.
Also it is not the best way to do but one of the best ways to do:)
With your terminal open and the Python Interactive shell started, you’ll see a command prompt consisting of three arrows (>>>). The code follows after it.
Type 10 in the terminal
Exploring The Python REPL
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, you don’t type in the three arrows, only what follows after it.
Now type in the number 10:
>>> 10 10
What happened? Remember we are in a REPL, which is short for Read-Evaluate-Print-Loop:
- Read: Python reads 10
- Evaluate: Python evaluates this input and decides it is a number
- Print: it prints out what was evaluated
- Loop: and it’s ready for the next input
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.
Comments
Post a Comment