Just enough terminal
The terminal scares beginners because it looks like a hacker movie. You need exactly three skills to survive:
1. See where you are and what is there. On Windows PowerShell:
dir
On macOS/Linux the command is ls. Both list the files in the current folder.
2. Move between folders with cd:
cd Documents\python-course
3. Tab-completion. Type the first few letters of a folder name and press Tab — the terminal finishes it for you. This saves typos and time. Use it constantly.
The REPL: your experiment bench
Type python (just that, nothing after it) and press Enter:
python
Python 3.12.4 (tags/v3.12.4) [MSC v.1938 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
The >>> prompt is the REPL (Read-Eval-Print Loop). Whatever you type, Python evaluates immediately. It is a perfect calculator:
>>> 250 * 4
1000
>>> 15000 / 3
5000.0
>>> 2 ** 10
1024
The REPL is where you experiment: "what does this do?" — try it, see instantly. To leave, type exit() and press Enter.
Your first script file
The REPL forgets everything when you close it. Real programs live in files. In VS Code, open your python-course folder (File → Open Folder), create a new file called hello.py, and type:
print("Hello from Lagos!")
print("This program lives in a file.")
Save it (Ctrl+S). Now run it from the terminal:
python hello.py
Hello from Lagos!
This program lives in a file.
REPL vs script: when to use which
- REPL — quick experiments, checking what a function does, doing maths. Throwaway.
- Script file — anything you want to keep, run again, or submit. Permanent.
A good workflow: test an idea in the REPL, then write the real version in a .py file. You will do exactly this all course.
Try it now
In the REPL, calculate: how much is 3 months of a ₦25,000/month data plan? Then how many ₦200 airtime top-ups fit in ₦5,000? (Hint: // does whole-number division — try 5000 // 200.) Then create about.py that prints your name and your state of origin, and run it with python about.py.