Programming fundamentalsLesson 1 of 2 in the course Expressions

Using the Python Interactive Shell and REPL

5 flashcards · 5 quiz questions · 5 match pairs · 5 fill-in sentences · English

Lesson progress
0 / 5

Your progress is kept in this browser only.Sign up to save it

Summary

The Python shell lets you enter Python code one line at a time and see what happens immediately. It is useful for learning, trying expressions, and troubleshooting mistakes without having to run a complete program each time.

Python is a high-level language: its code is designed to be readable by people. Computers ultimately run machine code, which consists of low-level instructions. A program must be translated into machine code to run.

All flashcards

What is the Python interpreter?
The interpreter translates Python source code into instructions the computer can run and executes the code. In an interactive shell, it handles code a line at a time.
What is a Python shell?
A shell, also called a console or terminal, is a program for interacting directly with the Python interpreter. It accepts code interactively and shows results or errors.
What does REPL mean?
REPL means read-eval-print loop: the shell reads code, evaluates it, prints any result, and then loops back to accept more code.
How do the shell's up and down arrows work?
The up arrow recalls the previous command in the shell history. The down arrow moves forward to the next command in that history.
How can shell history help correct a mistake?
Recall the mistaken command with the up arrow, edit the incorrect part, and press Enter to run the corrected command.

Quiz questions

  1. What does the Python interpreter do?Answer: It translates and executes Python source code as the program runs.
  2. What normally happens when a standalone expression is entered in the Python shell?Answer: The expression is evaluated and its result is displayed.
  3. What happens when Python evaluates `y / 0`?Answer: Python reports an error because division by zero is undefined.
  4. What normally happens after `x = 5` is entered in a Python shell?Answer: The value `5` is stored in `x`, usually without displaying a result.
  5. Which built-in function corrects the misspelling `intput(...)` when requesting user input?Answer: `input(...)`

Based on Introduction to Python Programming by Udayan Das, Aubrey Lawson, Chris Mayfield, Narges Norouzi (OpenStax), licensed CC BY 4.0. Adapted into a summary, flashcards and quizzes.

All Programming fundamentals lessons