Run Python on Your Computer
Optionally check for Python 3, save the temperature report as a plain-text file, and run it from a terminal. Browser execution remains the Core path.
The Core lessons run Python in the browser. Local Python is optional at this stage, but it becomes useful when you want to keep scripts as ordinary files or work without this page open.
Check for Python 3
A terminal is a text window for running commands. On macOS, open Terminal from Spotlight. On Windows, open PowerShell from the Start menu. On Linux, open the terminal application supplied with your desktop.
On macOS or Linux, try:
python3 --version
In Windows PowerShell, try:
python --version
If Windows does not recognize python, also try py --version. A result
beginning with Python 3 shows that the command found Python 3. The final
version number may differ. If neither command works, follow the installation
instructions for your operating system at
python.org.
After installation, close and reopen the terminal before checking again. This gives the terminal a chance to see the new command.
Save a Python File
Before saving the file, ask the terminal which folder it has opened. On macOS
or Linux, run pwd. In PowerShell, run Get-Location. The command displays a
folder path. Save a plain-text file named temperature_report.py in that
folder, and put this source code inside it:
The .py ending identifies the file as Python source. A word processor is not
suitable because it may store formatting data alongside the text. Use a code
editor or another editor that saves plain text.
Run the Saved File
Because the file is in the folder displayed by the terminal, we can run it without changing folders. On macOS or Linux, use:
python3 temperature_report.py
In Windows PowerShell, use:
python temperature_report.py
If py --version was the command that worked earlier, use
py temperature_report.py instead.
The report should match the browser result:
total: 82
count: 4
mean: 20.5
If Python says that it cannot open the file, check the folder and filename.
On macOS or Linux, pwd shows the current folder and ls lists its contents.
In PowerShell, Get-Location shows the current folder and Get-ChildItem
lists its contents. The list should contain temperature_report.py.
The Python command and the source filename have different roles:
python3,python, orpystarts Python;temperature_report.pynames the source file Python should run.
Keep the Browser Path Available
Local setup differs across computers, operating systems, school machines, and managed work devices. It should not block the Python curriculum. If local setup becomes distracting, return to the browser runner and continue the Core path. You can revisit this page when a later file-based or numerical project makes a local environment useful.
References
- Downloading Python — official Python installers and platform links.
- Using Python — official notes for running Python on Unix-like systems, Windows, and macOS.