Practice set — covers SL No 17–20 (installing Python, running scripts, and the interactive shell). Answer each from memory before opening the solution.
-
💡 Solution & explanation
Answer: Read–Eval–Print–Loop — the interactive Python shell you start by typing
python(orpython3) with no file.Explanation: It reads one statement, evaluates it, prints the result, and loops. It's ideal for quick experiments, testing a snippet, or inspecting objects — but it doesn't save your work, so use a script file for anything real.
-
💡 Solution & explanation
Answer:
python app.py
(or
python3 app.pyon systems wherepythonstill means Python 2).Explanation: The interpreter executes the file top to bottom. You must be in the file's directory or give its full/relative path.
-
💡 Solution & explanation
Answer:
python --version
Explanation: It prints something like
Python 3.12.1. On macOS/Linux, the system may ship an oldpython; preferpython3andpip3to be explicit about Python 3.
Q4. What's the practical difference between working in the REPL and writing a .py file in an editor/IDE?
-
💡 Solution & explanation
Answer: The REPL is ephemeral and line-by-line (great for exploration, lost on exit); a
.pyfile is saved, repeatable, and shareable, and is how you build real programs.Explanation: Editors/IDEs (VS Code, PyCharm) add syntax highlighting, autocomplete, debugging, and a run button, making larger projects manageable in a way the bare REPL cannot.