Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 0.5 — The Interactive Shell (REPL)
Python · Example 2 of 2

What the REPL shows vs what print shows

repr() gives the programmer's view that the REPL displays. For text it keeps the quotes, so you can tell '5' (text) from 5 (a number).

Typing python with no file name opens the interactive shell, where Python runs each line as soon as you press Enter and shows the result. It is the fastest way to try an idea, check how something behaves, or use Python as a calculator.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 5 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

A file contains the two lines 100 / 8 and print(100 / 8). What does running it print?

02

Write a program that prints both the reader's view and the programmer's view of the text 42.

03

You see this in documentation: >>> len("hello") followed by 5. Write the line you would put in a file to see the same answer.

Explain it without notes

01

What does REPL stand for, and what happens at each step?

02

Why does typing 2 + 3 show 5 in the REPL but nothing when it is a line in a file?

03

In the REPL, why does name show 'Asha' with quotes while print(name) shows Asha without?

04

When would you use the REPL and when a file?

What the REPL shows vs what print shows
Sign in to run this example in your browser.

Expected output

Asha
'Asha'
5 5
5 '5'