Review
Key Ideas
- Python runs exact code.
- A script is a saved file that Python can rerun.
- The terminal can start Python and pass it a file to run.
- An interactive session is useful for small checks.
- Output is what the program prints.
- Errors are reports about where Python got stuck.
- Change one thing, rerun, and compare.
Key Commands
| Command | Use |
|---|---|
python3 --version | check Python 3 on macOS or Linux |
py -3 --version | check Python 3 on Windows |
python --version | alternate version check on some systems |
python3 hello.py | run a script on macOS or Linux |
py -3 hello.py | run a script on Windows |
pwd | show the current folder |
ls | list files on macOS or Linux |
dir | list files in Windows PowerShell |
Common Mistakes
| Mistake | Fix |
|---|---|
| Running a command that does not exist on your system | try the command for your operating system |
| Running a file from the wrong folder | check the current folder and file name |
Pasting >>> into a script | remove the interactive prompt marker |
| Reading the whole traceback at once | start near the last useful line |
| Editing many things before rerunning | change one thing at a time |
Checklist
You are ready to move on if you can:
- explain what
print()does - run a tiny script
- predict the output of two
print()lines - recognize a Python 3 version
- read a basic
NameError - edit one value and rerun the code
If You Feel Lost
Return to the smallest possible script:
Run it. Change one word. Run it again. Confidence comes from seeing the loop work repeatedly.