Lesson 11: Module 1 Hands-on Projects
Apply everything you've learned in Module 1 by building four practical Python projects from scratch.
Lesson 11: Module 1 Hands-on Projects
It’s time to stop watching and start building! In this lesson, we will combine everything we’ve learned—variables, input, math, logic, and loops—to build four functional mini-applications.
Project 1: Simple Calculator
This project practices Input, Math, and Conditionals.
The Goal: Create a program that takes two numbers and an operator (+, -, *, /) and prints the result.
print("--- Python Calculator ---")
num1 = float(input("Enter first number: "))
op = input("Enter operator (+, -, *, /): ")
num2 = float(input("Enter second number: "))
if op == "+":
print(f"Result: {num1 + num2}")
elif op == "-":
print(f"Result: {num1 - num2}")
elif op == "*":
print(f"Result: {num1 * num2}")
elif op == "/":
if num2 != 0:
print(f"Result: {num1 / num2}")
else:
print("Error: Cannot divide by zero!")
else:
print("Invalid operator.")
Project 2: Number Guessing Game
This project practices Loops and Randomness.
The Goal: The computer picks a number, and you have to guess it.
import random
print("Welcome to the Guessing Game!")
secret_number = random.randint(1, 100)
attempts = 0
while True:
guess = int(input("Guess a number between 1 and 100: "))
attempts += 1
if guess < secret_number:
print("Too low!")
elif guess > secret_number:
print("Too high!")
else:
print(f"Correct! It took you {attempts} attempts.")
break
Project 3: Temperature Converter (Enhanced)
This project practices Logic and Unit Conversions.
The Goal: A universal converter for Celsius, Fahrenheit, and Kelvin.
temp = float(input("Enter temperature value: "))
unit = input("Is this (C)elsius, (F)ahrenheit, or (K)elvin? ").upper()
if unit == "C":
f = (temp * 9/5) + 32
k = temp + 273.15
print(f"{temp}C is {f}F and {k}K")
elif unit == "F":
c = (temp - 32) * 5/9
k = c + 273.15
print(f"{temp}F is {c}C and {k}K")
# ... add logic for Kelvin yourself!
Project 4: Command-line To-Do App
This project practices Loops and List-like logic (though we’ll use basic variables for now).
The Goal: A simple menu-driven app that keeps "running" until you quit.
print("--- My To-Do App ---")
todo_list = ""
is_running = True
while is_running:
print("\n1. Add Task")
print("2. View Tasks")
print("3. Exit")
choice = input("Select an option: ")
if choice == "1":
new_task = input("Enter the task: ")
todo_list += f"- {new_task}\n"
elif choice == "2":
print("\nYour Current Tasks:")
print(todo_list if todo_list else "No tasks yet.")
elif choice == "3":
is_running = False
print("Goodbye!")
else:
print("Invalid choice.")
Bonus Challenge
Try to combine Project 1 and Project 4. Can you make the Calculator stay open and ask "Would you like to do another calculation?" after each result?
What’s Next?
Congratulations on finishing your first set of projects! To wrap up Module 1, head over to the Exercises & Quiz section to solidify your knowledge before we move on to Module 2: Data Structures and Algorithms!