The best way to learn Python is not to read about it — it is to write small programs that actually run. Here are seven beginner programs, in order, that take you from your very first line of code to real logic. Type each one yourself; don’t copy-paste.
1. Say hello
print("Hello, world!")
Your first program. print() shows text on the screen.
2. Greet the user
name = input("What is your name? ")
print("Nice to meet you, " + name)
Now your program listens. input() reads what the user types.
3. A simple calculator
a = int(input("First number: "))
b = int(input("Second number: "))
print("Sum =", a + b)
int() turns text into a number so you can do maths with it.
4. Odd or even
n = int(input("Enter a number: "))
if n % 2 == 0:
print("Even")
else:
print("Odd")
Your first decision. % gives the remainder; if it’s 0, the number is even.
5. Count to ten
for i in range(1, 11):
print(i)
Loops let the computer repeat work for you — the heart of programming.
6. Multiplication table
num = int(input("Table of: "))
for i in range(1, 11):
print(num, "x", i, "=", num * i)
7. Guess the number
import random
secret = random.randint(1, 10)
guess = int(input("Guess 1-10: "))
if guess == secret:
print("Correct!")
else:
print("Nope, it was", secret)
Your first real “game” — combining input, randomness and decisions.
Keep going
Once these feel easy, you’re ready for projects. Our coding batches for school students take you from here to building real apps and games. See school coding courses or book a free demo.
