1. The Classic: Hello, World!
Every programmer starts here. It teaches you how to print text to the screen.
Python
# This program prints a greeting
print("Hello, World!")
2. The Interactive: Greeting Bot
This program asks for your name and greets you personally. It introduces how to take user input
and use variables.
Python
# Asking for user input
name = input("What is your name? ")
# Printing a personalized message
print("Nice to meet you, " + name + "!")
What you learn: The input() function and string concatenation (gluing text together using
+).
3. The Calculator: Area of a Rectangle
Let's do some quick math. This program calculates the area of a rectangle based on user
measurements.
Python
# Taking input and converting it from text (string) to a decimal number
(float)
length = float(input("Enter the length: "))
width = float(input("Enter the width: "))
# Calculating the area
area = length * width
# Displaying the result
print("The area of the rectangle is:", area)
What you learn: Typecasting (converting text input into numbers using float()) and basic
arithmetic.
4. The Decision Maker: Odd or Even?
This program checks whether a number entered by the user is odd or even.
Python
number = int(input("Enter a whole number: "))
# The % (modulo) operator gives the remainder of a division.
# If a number divided by 2 has a remainder of 0, it's even.
if number % 2 == 0:
print("That's an even number!")
else:
print("That's an odd number!")
What you learn: Conditional statements (if/else) and the modulo operator (%).
5. The Mini-Game: Guess the Number
A simple game where the computer picks a random number, and you have to guess it.
Python
import random
# The computer picks a random number between 1 and 10
secret_number = [Link](1, 10)
guess = 0
print("I'm thinking of a number between 1 and 10. Can you guess it?")
# A loop that keeps running until you guess correctly
while guess != secret_number:
guess = int(input("Take a guess: "))
if guess < secret_number:
print("Too low! Try again.")
elif guess > secret_number:
print("Too high! Try again.")
else:
print("You got it! Standard genius behavior.")
What you learn: Importing Python modules (import random), while loops, and elif
(else-if) logic.
Cheat Sheet: Quick Terminology
Concept What it means Example
Variable A container for storing data. x = 5
String Text wrapped in quotes. "Python"
Integer / Float Whole numbers / Decimal numbers. 10 or 10.5
Loop A block of code that repeats. while or for