Your first program
No blocks. An empty white page. For the first time, the computer asks what you want instead of offering a list.
- Make Python print and ask
- Predict what a program will do, then run it
- Read two error messages calmly
Your first program
No blocks. An empty white page. For the first time, the computer asks what you want instead of offering a list.
- Make Python print and ask
- Predict what a program will do, then run it
- Read two error messages calmly
Story
move 10 steps out of a drawer. In Class 7 he had snapped if touching colour into place. The blocks were always there, waiting to be used, and you could not spell one wrong.Learn it
In Scratch you dragged blocks out of a drawer and could never spell one wrong. In Python you
write every instruction yourself, so every bracket and every quote matters. Two instructions are
enough to start: print puts something on the screen, and input asks a question and waits.
The program runs top to bottom, one line at a time, and when it can't understand a line, it tells
you which one.
Words to know
a programming language you write as text. Files are saved with the ending .py.
in Thonny, the editor (top) is where you write and save; the shell (bottom) is where the program runs and answers.
shows something on the screen. Text inside quotes is printed exactly as typed.
shows a question, then stops and waits for the person to type an answer.
a name without quotes that holds a value, like name holding whatever the person typed.
text inside quotes, like "Salaam!".
Python could not understand a line, usually a missing bracket or quote. It names the line.
Step by step: a dry run before you press F5
print("Welcome to the library")
book = input("Which book? ")
print("You asked for", book)
- Line 1 runs: the screen shows
Welcome to the library. - Line 2 runs: it shows
Which book?and waits. Suppose the person typesGhalib; now the variablebookholdsGhalib. - Line 3 runs: the screen shows
You asked for Ghalib. The quotes mark fixed text;bookwithout quotes means what's in the box. - Break it on purpose: delete the last
"on line 1 and run. Python stops withSyntaxError: unterminated string literal: you opened a quote and never closed it. Put it back.
Working out what a program will do before running it is called a dry run. Good programmers do it all the time.
Careful: an error message tells you where Python stopped, not that you failed. Read the last line,
go to the line it names, fix one thing, run again. And Print is not print: Python cares about
capitals.
Your missions
Make it say something
8 min- 1
In the editor (top), type exactly:
print("Salaam!"). Save it as01-greeting.py. - 2
Predict: will the quotes show on screen? Then press F5. The output appears in the shell (bottom).
Only you can see this - 3
Add two lines, so it greets in three languages. Predict how many lines of output, then run:
print("Salaam!") print("Assalamu alaikum!") print("Hello!")
Make it ask something
6 min- 4
Add these, run, and type your name when it waits:
name = input("What is your name? ") print("Salaam,", name) - 5
Run it twice with different names. The program doesn't change; the output does.
Break it on purpose
5 min- 6
Delete the last
"in line 1. Predict: print, nothing, or refuse? Run it:SyntaxError: unterminated string literal— you opened a quote and never closed it. - 7
Put it back, delete the closing
)instead, and run:SyntaxError: '(' was never closed. Fix it and save — your first program to keep.
Stuck?
F5 does nothing? Thonny saves before running — give the file a name. Red text you can't
read? Read only the last line. print not coloured? Check the spelling: Print isn't
print.
Ask for the person's village too, and print a two-line greeting using both answers.
No laptop today?
Do a dry run in your notebook: copy a four-line program with one input, and write what
appears on screen line by line, assuming the person types Hiba. Mark where it stops and
waits.
Debate it
Thonny tells you unterminated string literal instead of "something is wrong".
Which is more useful to a beginner, and why? Now think of a person, not a program: when you correct a classmate's mistake, are you telling them where it went wrong, or only that it did?
Check yourself · practice, not a test
In the app, students answer these one at a time and each answer is checked straight away. It's practice, never a mark — anything they miss comes back later for another go.
1.What does input() do that print() does not?
- AIt runs faster
- BIt stops and waits for the person at the keyboard
- CIt saves the file
- DIt writes in colour
2.A Python file must be saved with the ending ______ .
3.What does this print? python print("Salaam") print("Kashmir")
- ASalaam Kashmir on one line
- BSalaam on one line, then Kashmir on the next
- CSalaamKashmir
- DNothing, it is wrong
4.Find the bug. This line will not run: print("Good morning)
- Aprint should be Print
- BThe closing " is missing
- CIt needs a full stop at the end
- DBrackets are not allowed
5.An error message means you should stop and ask the teacher before trying anything yourself.
TrueFalse6.Put these lines in the order they must appear, so the program asks before it greets:
- 1name = input("What is your name? ")
- 2print("Salaam,", name)
- 3print("Welcome to Class 9")
Type it exactly. Run it. Read the last line of the error. Fix one thing.
Typing practice
Today's symbols are the round brackets ( ) and the double quote ".
Every Python line you write this year will use them.
(is Shift + 9.)is Shift + 0."is Shift + ' — the key beside Enter.- typing.com: the punctuation and symbols lessons.
- Then type this line five times, with no mistakes, in the typing box or your notebook:
print("Salaam")
Speed does not matter today. A bracket in the wrong place is a program that will not run, so accuracy is the whole exercise.
- (
- )
- "
- (
- )
- "
- print("Salaam")
Written and designed by Faizan Ayoub. © 2026 Faizan Ayoub. All rights reserved.