INTRODUCTION
Run a program
A program is a file of steps.
press Enter ↵
C:\Users\you\Documents
diarymusicmy-projectstoriesvault
⬆ Documents is inside you

Windows PowerShell (practice mode: nothing here touches your real computer)

 

Lesson 22: Running programs

Level 3, Terminal Power and Safety. Run a Python file from the terminal, then write your own. The new word: Python. It follows lesson 21, Stop signs. Next comes lesson 23, Practice: the clean-up mission.

What the lesson explains

Run a program. A program is a file of steps.

Python runs hello.py. python is the program; hello.py holds the steps. On the card: python hello.py

What you do first

Read it, then run it. In the practice terminal, type cat hello.py at the prompt PS C:\Users\you\Documents\my-project> and the computer answers: print("Hello").

The files on the practice computer

This lesson works in one folder. At the start, Documents\my-project holds backups\, club\, games\, images\, my-games\, hello.py, notes.txt, shopping.txt.

Along the way you type echo 'print("Hi, I am a program")' > hi.py. Lesson 23 opens with the files just as you leave them.

What you practise

Try it, "Read it, then run it": In the practice terminal, type cat hello.py at the prompt PS C:\Users\you\Documents\my-project> and the computer answers: print("Hello"). Then: In the practice terminal, type python hello.py at the prompt PS C:\Users\you\Documents\my-project> and the computer answers: Hello. Then: In the practice terminal, type python --version at the prompt PS C:\Users\you\Documents\my-project> and the computer answers: Python 3.12.4.

Challenge, "Your first program": Write a program called hi.py and run it. Starting at PS C:\Users\you\Documents\my-project>, one way takes 2 commands: echo 'print("Hi, I am a program")' > hi.py; python hi.py (par: 2).

One more, "Other programs": In the practice terminal, type notepad notes.txt at the prompt PS C:\Users\you\Documents\my-project> and the computer answers: (Notepad opens notes.txt in a new window. On the practice computer, cat shows what is inside.).

What PlayBuddy and PlayType say

PlayType: "A program is a file full of steps. The computer can run it for you."

PlayBuddy: "Python reads the file and does each step. Next level, you write your own!"

Help in every lesson

Everything happens on a pretend computer in your browser, so nothing touches your real files. PlayBuddy and PlayType stand beside the board, cheer you on and say when it is your turn.

A green ring shows where to click the first time. After that you do it on your own, and if you slip twice the ring comes back.

Stars

The lesson has 5 things to do. Up to one slip in ten gives three stars, up to one in four gives two, and finishing always gives at least one. Stars and progress are saved in this browser only; there is no account.

About DayOneCode

DayOneCode is an independent learning site, not affiliated with or endorsed by Anthropic. Claude and Claude Code are trademarks of Anthropic.