CODE FROM ZERO
A Complete 2-Week Beginner's Course in Python
Learn to code — step by step, day by day
Language Python 3
Duration 14 Days • ~1–2 hrs/day
Level Absolute Beginner
Goal Build real programs & think like a developer
Welcome! This course takes you from zero experience to writing real Python programs in just two weeks.
Every day has clear lessons, examples you can type yourself, and practical exercises. No prior knowledge
needed — just curiosity and a computer.
Table of Contents
Week 1 —
Foundations
Day 1 Setting Up & Your First Program
Day 2 Variables & Data Types
Day 3 User Input & String Magic
Day 4 Making Decisions — If / Else
Day 5 Loops — Repeating Yourself (Smartly)
Day 6 Lists & Collections
Day 7 Week 1 Project — Number Guessing Game
Week 2 — Going
Deeper
Day 8 Functions — Your Own Commands
Day 9 Dictionaries & Sets
Day 10 File Reading & Writing
Day 11 Error Handling
Day 12 Modules & the Standard Library
Day 13 Introduction to Object-Oriented Programming
Day 14 Final Project & Next Steps
■ WEEK 1 — FOUNDATIONS
This week you will install Python, understand core concepts, and write your first real programs. By Day 7
you'll build a complete game from scratch.
DAY 1
Setting Up & Your First Program
What You'll Learn
Topics Exercises
• What Python is • Print your name 10 ways
• Install Python & VS Code • Calculate your age in days
• Run your first script • Display today's date
• Understand print() • Write a greeting program
• Python interactive shell (REPL)
Why Python?
Python is the world's most beginner-friendly programming language. It reads almost like English, runs on
every operating system, and powers everything from websites to AI. Companies like Google, Netflix, and
NASA use Python daily.
Installation Guide
Step-by-step setup
• Go to [Link]/downloads and download Python 3.12 (or newer)
• Run the installer — check 'Add Python to PATH' before clicking Install
• Download VS Code from [Link]
• In VS Code, open Extensions (Ctrl+Shift+X) and install the 'Python' extension
• Open a terminal in VS Code (Ctrl+`) and type: python --version
Your First Program
Create a new file called [Link] and type exactly this:
print("Hello, World!") print("My name is Alex") print("I am learning Python!")
Run it with: python [Link] — you should see three lines of output. Congratulations, you are now a
programmer!
How print() Works
print() is a function — a reusable command built into Python. Whatever you put inside the parentheses
(surrounded by quotes) gets displayed on screen. The quotes tell Python 'this is text, not code'.
Day 1 Exercises
✓ Print your full name, city, and favourite colour on three separate lines
✓ Print a simple ASCII drawing using multiple print() statements
✓ Try running python in the terminal and typing print('Hello') directly — this is the REPL
✓ Write a program that prints a 5-line poem (any topic you like)
■ TIP: If you see a SyntaxError, look for missing quotes or parentheses. Python is very picky about
punctuation!
DAY 2
Variables & Data Types
Topics Exercises
• Variables (storing data) • Temperature converter
• Integers & floats • Simple calculator
• Strings • Area of a rectangle
• Booleans • BMI calculator
• Type checking with type() • Seconds to hours/minutes
• Basic arithmetic
What is a Variable?
A variable is a labelled box that holds a value. You create one by writing a name, then = then the value.
Python figures out the type automatically.
age = 25 name = "Alex" height = 1.75 is_student = True print(age) print(name)
print(type(age)) # Output: <class 'int'>
The Four Main Data Types
Type Example Used For
int 42, -7, 0 Whole numbers, counting
float 3.14, -0.5 Decimal numbers, measurements
str "Hello" 'World' Text, names, messages
bool True False Yes/No, on/off decisions
Arithmetic Operators
x = 10 y = 3 print(x + y) # 13 (addition) print(x - y) # 7 (subtraction) print(x * y)
# 30 (multiplication) print(x / y) # 3.333... (division) print(x // y) # 3 (floor
division) print(x % y) # 1 (remainder/modulo) print(x ** y) # 1000 (power)
String Operations
first = "John" last = "Smith" full = first + " " + last # Concatenation greeting =
f"Hello, {full}! You have {5} messages." # f-string print(greeting)
■ NOTE: f-strings (starting with f") let you embed variables directly inside text using curly braces {}. They are
the modern, preferred way to build strings in Python.
Day 2 Exercises
✓ Store your name, age, and height in variables, then print them in a sentence
✓ Build a temperature converter: ask for Celsius, calculate Fahrenheit (F = C * 9/5 + 32)
✓ Calculate the area and perimeter of a rectangle using variables
✓ Write a program to calculate how many days old you are (age * 365)
DAY 3
User Input & String Magic
Topics Exercises
• input() function • Personal greeting app
• Converting input types • Mad Libs generator
• String methods • Name statistics
• String slicing • Initials extractor
• len() function • Word counter
• String formatting
Getting Input from the User
Programs become interactive with input(). It pauses and waits for the user to type something and press
Enter. The result is always a string.
name = input("What is your name? ") age_str = input("How old are you? ") age =
int(age_str) # Convert string to integer print(f"Hello {name}, you are {age} years
old!") print(f"Next year you will be {age + 1}.")
■■ WARNING: input() always returns a string. If you need a number, convert it with int() for whole numbers
or float() for decimals. Forgetting this is a very common mistake!
Essential String Methods
Method Example Result
.upper() "hello".upper() "HELLO"
.lower() "WORLD".lower() "world"
.strip() " hi ".strip() "hi"
.replace(a,b) "cat".replace("c","b") "bat"
.split() "a,b,c".split(",") ['a','b','c']
.count(x) "banana".count("a") 3
.startswith(x) "hello".startswith("he") True
len() len("hello") 5
String Slicing
text = "Python" print(text[0]) # "P" — first character print(text[-1]) # "n" — last
character print(text[0:3]) # "Pyt" — characters 0,1,2 print(text[2:]) # "thon" —
from index 2 to end print(text[::-1]) # "nohtyP" — reversed!
Day 3 Exercises
✓ Write a Mad Libs program: ask for a noun, verb, adjective, then print a funny story
✓ Ask for a full name, then print: first name, last name, initials, and total letter count
✓ Build a 'string inspector': input any word and print it reversed, uppercased, and its vowel count
✓ Make a simple form: collect name, city, and hobby, then print a formatted summary
DAY 4
Making Decisions — If / Else
Topics Exercises
• if statement • Grade calculator
• else clause • Age category checker
• elif (else if) • Login validator
• Comparison operators • Number sign detector
• Logical operators (and/or/not) • Rock Paper Scissors
• Nested conditions
The if Statement
Conditions let your program make choices. If the condition is True, the indented block runs. Otherwise it's
skipped. Indentation (4 spaces) is mandatory in Python!
temperature = int(input("Enter temperature in °C: ")) if temperature > 30:
print("It's hot! Wear light clothes.") elif temperature > 15: print("Nice weather. A
light jacket is fine.") elif temperature > 0: print("It's cold. Bundle up!") else:
print("Freezing! Stay indoors if possible.")
Comparison Operators
Operator Meaning Example Result
== Equal to 5 == 5 True
!= Not equal 5 != 3 True
> Greater than 7 > 3 True
< Less than 2 < 8 True
>= Greater or equal 5 >= 5 True
<= Less or equal 4 <= 3 False
Logical Operators
age = 20 has_ticket = True if age >= 18 and has_ticket: print("Welcome to the
event!") score = 85 if score >= 90 or score == 85: # 85 is special print("Great
score!") logged_in = False if not logged_in: print("Please log in first.")
Day 4 Exercises
✓ Grade calculator: ask for a score (0-100) and print A/B/C/D/F
✓ Age checker: determine if someone is a child, teen, adult, or senior
✓ Divisibility: check if a number is even/odd AND divisible by 5
✓ Simple login: check username AND password, print success or failure message
DAY 5
Loops — Repeating Yourself (Smartly)
Topics Exercises
• for loop • Multiplication table
• while loop • Countdown timer
• range() function • Sum calculator
• break & continue • Password retry system
• Nested loops • Star pattern printer
• Loop + if together • FizzBuzz
The for Loop
Use a for loop when you know how many times you want to repeat — or when you want to go through every
item in a collection.
# Count from 1 to 5 for i in range(1, 6): print(i) # Loop over a list of items
fruits = ["apple", "banana", "cherry"] for fruit in fruits: print(f"I like {fruit}")
# Range with step: count by 2s for i in range(0, 11, 2): print(i, end=" ") # 0 2 4 6
8 10
The while Loop
Use a while loop when you want to repeat until a condition becomes False. Be careful — if the condition
never becomes False you get an infinite loop!
count = 1 while count <= 5: print(f"Count: {count}") count += 1 # Real-world
example: keep asking until valid input guess = "" while guess != "quit": guess =
input("Type something ('quit' to stop): ") print(f"You typed: {guess}")
break and continue
# break: exit the loop immediately for i in range(10): if i == 5: break print(i) #
prints 0 1 2 3 4 # continue: skip this iteration for i in range(10): if i % 2 == 0:
continue print(i) # prints 1 3 5 7 9 (odd numbers only)
FizzBuzz — Classic Exercise
# For numbers 1-30: # Print "Fizz" if divisible by 3 # Print "Buzz" if divisible by
5 # Print "FizzBuzz" if divisible by both for n in range(1, 31): if n % 15 == 0:
print("FizzBuzz") elif n % 3 == 0: print("Fizz") elif n % 5 == 0: print("Buzz")
else: print(n)
■ TIP: FizzBuzz is a famous coding interview question. Once you understand loops and conditionals, it's
easy — but it trips up people who can't code at all.
Day 5 Exercises
✓ Print a multiplication table for any number the user enters
✓ Sum all numbers from 1 to 100 using a loop (answer: 5050)
✓ Print a triangle of stars: 1 star on row 1, 2 on row 2, up to 5
✓ FizzBuzz: implement it yourself before looking at the solution above
DAY 6
Lists & Collections
Topics Exercises
• Creating lists • Shopping list manager
• Accessing items by index • Average calculator
• Slicing lists • Highest/lowest finder
• List methods (append, remove, sort) • Duplicate remover
• Looping over lists • To-do list app
• List comprehensions (intro)
What is a List?
A list stores multiple values in a single variable, in order. Items can be any type, and lists can grow or shrink.
They are one of Python's most-used features.
numbers = [3, 1, 4, 1, 5, 9, 2, 6] fruits = ["apple", "banana", "cherry"] mixed =
[42, "hello", True, 3.14] # Indexing (starts at 0) print(fruits[0]) # "apple"
print(fruits[-1]) # "cherry" (last item) # Slicing print(numbers[2:5]) # [4, 1, 5]
Key List Methods
shopping = ["milk", "eggs", "bread"] [Link]("butter") # Add to end
[Link](0, "apples") # Insert at position 0 [Link]("eggs") # Remove
by value popped = [Link]() # Remove & return last item numbers = [3, 1, 4, 1,
5] [Link]() # Sort ascending: [1,1,3,4,5] [Link](reverse=True) # Sort
descending print(len(numbers)) # 5 print(sum(numbers)) # 14 print(max(numbers)) # 5
print(min(numbers)) # 1
List Comprehension (Superpower)
List comprehensions create new lists in one line — much cleaner than a loop.
# Old way squares = [] for n in range(1, 6): [Link](n ** 2) # List
comprehension (same result) squares = [n ** 2 for n in range(1, 6)] print(squares) #
[1, 4, 9, 16, 25] # With a filter evens = [n for n in range(20) if n % 2 == 0]
print(evens) # [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
Day 6 Exercises
✓ Build a shopping list manager: add items, remove items, display all items
✓ Ask for 5 numbers, store in a list, print sum, average, max, and min
✓ Remove all duplicates from a list [1,2,2,3,3,3,4] without using set()
✓ Use a list comprehension to get all words longer than 4 letters from a sentence
DAY 7
Week 1 Project — Number Guessing Game
Today you apply everything from Week 1 to build a complete, working game. Read the full project
description before writing a single line of code.
Project: Number Guessing Game
Features to implement
• Computer picks a random number between 1 and 100
• Player has 7 attempts to guess the number
• After each guess: tell the player 'Too high', 'Too low', or 'Correct!'
• Count the number of guesses used
• At the end: show how many guesses were needed (or 'You ran out of guesses!')
• Ask if the player wants to play again
Starter Code
import random def play_game(): secret = [Link](1, 100) max_guesses = 7
guesses_used = 0 print("I'm thinking of a number between 1 and 100.") print(f"You
have {max_guesses} guesses. Good luck!\n") while guesses_used < max_guesses: guess =
int(input(f"Guess #{guesses_used + 1}: ")) guesses_used += 1 if guess < secret:
print("Too low! Try higher.") elif guess > secret: print("Too high! Try lower.")
else: print(f"\n■ Correct! You got it in {guesses_used} guess(es)!") return True
print(f"\n■ Out of guesses! The number was {secret}.") return False # Main game loop
play_again = "yes" while play_again.lower() in ["yes", "y"]: play_game() play_again
= input("\nPlay again? (yes/no): ") print("Thanks for playing!")
Concepts Used in this Project
✓ import random, [Link]() — Week 2 teaser: modules!
✓ while loop with a counter — Day 5
✓ if / elif / else — Day 4
✓ input() with int() conversion — Day 3
✓ Variables to track state — Day 2
✓ Functions (def play_game():) — a preview of Day 8
■ NOTE: Don't worry if you don't fully understand 'def' and 'import' yet — those are coming in Week 2. For
now just type the code and focus on making it run.
Stretch Challenges
Completed the base project? Try these:
• Track the player's all-time win/loss record across multiple games
• Add difficulty levels: Easy (1-50, 10 guesses), Hard (1-200, 5 guesses)
• Show a progress bar of remaining guesses using asterisks
■ WEEK 2 — GOING DEEPER
Week 2 elevates your skills with functions, data structures, files, and object-oriented programming. By Day
14 you'll have the knowledge to build almost any small application.
DAY 8
Functions — Your Own Commands
Topics Exercises
• def keyword • Calculator with functions
• Parameters & arguments • Unit converter
• Return values • Text stats counter
• Default parameters • Prime number checker
• Scope (local vs global) • Recursive countdown
• Docstrings
Defining Functions
Functions let you name and reuse a block of code. Instead of copying the same logic 10 times, write it once
and call it 10 times. This makes code shorter and easier to fix.
# Basic function def greet(name): """Return a greeting message.""" return f"Hello,
{name}! Welcome." result = greet("Alice") print(result) # Hello, Alice! Welcome. #
Multiple parameters def add(a, b): return a + b print(add(3, 5)) # 8 print(add(10,
20)) # 30 # Default parameter values def power(base, exponent=2): return base **
exponent print(power(5)) # 25 (uses default exponent=2) print(power(2, 10)) # 1024
Return Values
return sends a value back to whoever called the function. A function without return gives back None.
def celsius_to_fahrenheit(c): return c * 9/5 + 32 def is_even(n): return n % 2 == 0
# Returns True or False temps = [0, 20, 37, 100] for t in temps: f =
celsius_to_fahrenheit(t) print(f"{t}°C = {f:.1f}°F")
Variable Scope
# Variables inside functions are LOCAL — invisible outside def my_func(): x = 10 #
local variable print(x) my_func() # 10 # print(x) # NameError — x doesn't exist
here! # Global variables exist everywhere but are rarely modified inside functions
score = 0 def add_point(): global score score += 1 add_point() print(score) # 1
Day 8 Exercises
✓ Write a function calculate_bmi(weight_kg, height_m) that returns BMI and category
✓ Write is_prime(n) that returns True if n is prime, False otherwise
✓ Create a 4-function calculator (add, subtract, multiply, divide) as separate functions
✓ Write a function that takes a list of numbers and returns (min, max, average) as a tuple
DAY 9
Dictionaries & Sets
Topics Exercises
• Dictionary creation • Contact book
• Accessing & updating values • Word frequency counter
• Dictionary methods • Student grade tracker
• Looping over dicts • Unique word finder
• Sets (unique collections) • Menu ordering system
• Set operations
Dictionaries
Dictionaries store key-value pairs — like a real dictionary where you look up a word (key) to find its definition
(value). Keys must be unique.
person = { "name": "Alice", "age": 28, "city": "London", "hobbies": ["reading",
"coding"] } # Access values print(person["name"]) # "Alice" print([Link]("age"))
# 28 print([Link]("phone", "N/A")) # "N/A" (safe default) # Modify person["age"]
= 29 # Update existing person["email"] = "a@[Link]" # Add new key del person["city"]
# Delete key # Loop over for key, value in [Link](): print(f" {key}: {value}")
Sets
Sets store unique values with no duplicates and no guaranteed order. Perfect for membership tests and
removing duplicates.
a = {1, 2, 3, 4, 5} b = {4, 5, 6, 7, 8} print(a | b) # Union: {1,2,3,4,5,6,7,8}
print(a & b) # Intersection: {4, 5} print(a - b) # Difference: {1, 2, 3} # Remove
duplicates from a list words = ["apple","banana","apple","cherry","banana","apple"]
unique = list(set(words)) print(unique) # ['apple', 'banana', 'cherry'] (order may
vary)
Day 9 Exercises
✓ Build a contact book: store name→phone, allow add/search/delete
✓ Count word frequency in a sentence (use a dict: word → count)
✓ Store student grades in a dict; find highest, lowest, class average
✓ Given two lists of names, find people in both lists using sets
DAY 10
File Reading & Writing
Topics Exercises
• open() function • Note-taking app
• Read modes (r, w, a) • Log file writer
• Reading lines • Word counter from file
• Writing to files • CSV data reader
• with statement (context manager) • To-do list that saves to disk
• CSV basics
Reading Files
Files let your programs remember data between runs — instead of starting fresh every time, you can save
and load information.
# Read entire file with open("[Link]", "r") as f: content = [Link]()
print(content) # Read line by line with open("[Link]", "r") as f: for line in f:
print([Link]()) # Read all lines into a list with open("[Link]", "r") as f:
lines = [Link]() print(f"File has {len(lines)} lines")
Writing Files
# Write (creates new file or OVERWRITES existing) with open("[Link]", "w") as f:
[Link]("Line 1\n") [Link]("Line 2\n") # Append (adds to end without overwriting)
with open("[Link]", "a") as f: [Link]("New entry added\n") # Write multiple lines
at once lines = ["First", "Second", "Third"] with open("[Link]", "w") as f:
[Link](line + "\n" for line in lines)
Practical: To-Do List with File Storage
FILENAME = "[Link]" def load_todos(): try: with open(FILENAME) as f: return
[[Link]() for line in f if [Link]()] except FileNotFoundError: return [] def
save_todos(todos): with open(FILENAME, "w") as f: [Link](t + "\n" for t in
todos) todos = load_todos() [Link]("Buy groceries") [Link]("Call
dentist") save_todos(todos) print(todos)
Day 10 Exercises
✓ Write a journal app: let the user type an entry, append it (with date) to [Link]
✓ Read a text file and count: total words, total lines, most common word
✓ Build a persistent to-do list (add, view, remove tasks, saves to file)
✓ Create a simple CSV manually and read it back, printing each row as a dictionary
DAY 11
Error Handling
Topics Exercises
• try / except blocks • Safe number converter
• Common exception types • File checker
• else clause • Division guard
• finally clause • Validated age input
• Raising your own errors • Robust calculator
• Input validation
Why Handle Errors?
Without error handling, one bad input crashes your entire program. With it, you can gracefully handle
problems and keep the program running.
# Without error handling — CRASHES result = int("hello") # ValueError! # With error
handling — SAFE try: result = int("hello") print(f"Result: {result}") except
ValueError: print("That's not a valid number!") except ZeroDivisionError:
print("Cannot divide by zero!") except Exception as e: print(f"Unexpected error:
{e}") else: print("Everything worked!") finally: print("This always runs, success or
failure.")
Common Exception Types
Exception When it happens
ValueError Wrong type of value (int('abc'))
TypeError Wrong type of argument (len(42))
IndexError List index out of range (lst[99])
KeyError Dict key doesn't exist (d['missing'])
FileNotFoundError File doesn't exist on disk
ZeroDivisionError Dividing by zero (10 / 0)
NameError Variable doesn't exist (print(xyz))
Input Validation Pattern
def get_positive_int(prompt): """Keep asking until user gives a valid positive
integer.""" while True: try: value = int(input(prompt)) if value <= 0: raise
ValueError("Must be positive") return value except ValueError as e: print(f"Invalid:
{e}. Try again.") age = get_positive_int("Enter your age: ") print(f"Your age is
{age}")
Day 11 Exercises
✓ Wrap the Day 2 calculator in try/except to handle non-numeric input
✓ Safe file reader: try to open a file, print a friendly message if it doesn't exist
✓ Write get_int_in_range(min, max) that keeps asking until the user gives a valid number
✓ Add error handling to your to-do list app from Day 10
DAY 12
Modules & the Standard Library
Topics Exercises
• import statement • Dice roller
• random module • Date calculator
• datetime module • Trig calculator
• math module • File lister
• os module • JSON config reader
• json module • Password generator
• Creating your own module
What is a Module?
A module is a file full of reusable functions and tools. Python ships with hundreds of modules in its Standard
Library — free to use, no installation needed. You've already used 'random'!
Key Standard Library Modules
import random import math import datetime import os import json # random
print([Link](1, 6)) # Dice roll
print([Link](["rock","paper","scissors"])) [Link]([1,2,3,4,5]) #
Shuffle in place # math print([Link](144)) # 12.0 print([Link]) # 3.14159...
print([Link](4.1), [Link](4.9)) # 5 4 # datetime now =
[Link]() print([Link]("%Y-%m-%d %H:%M")) # 2025-06-15 14:30
birthday = [Link](1995, 8, 15) today = [Link]() print((today -
birthday).days, "days old") # os print([Link]()) # Current directory
print([Link](".")) # Files in folder [Link]("my_folder", exist_ok=True) #
json — save/load structured data data = {"name": "Alice", "scores": [95, 87, 92]}
with open("[Link]", "w") as f: [Link](data, f, indent=2) with
open("[Link]") as f: loaded = [Link](f) print(loaded["name"])
Creating Your Own Module
Any .py file is a module! Create [Link]:
# [Link] def greet(name): return f"Hello, {name}!" def is_palindrome(text): t =
[Link]().replace(" ", "") return t == t[::-1] # In your main script: # import
myutils # print([Link]("Bob")) # print(myutils.is_palindrome("racecar"))
Day 12 Exercises
✓ Build a password generator using random — mix letters, numbers, symbols
✓ Date calculator: how many days until your next birthday?
✓ Directory explorer: list all .py files in a folder using [Link]()
✓ JSON address book: save/load contacts as a JSON file
DAY 13
Intro to Object-Oriented Programming
Topics Exercises
• class keyword • BankAccount class
• __init__ method • Animal class hierarchy
• Instance variables • Rectangle class
• Methods • Student grade manager
• self parameter • Simple card game
• Inheritance basics
What is OOP?
Object-Oriented Programming lets you model real things as objects that combine data (attributes) and
actions (methods). A class is the blueprint; an object (instance) is the actual thing created from that
blueprint.
Your First Class
class Dog: """Represents a dog.""" def __init__(self, name, breed, age): """Called
automatically when you create a Dog.""" [Link] = name [Link] = breed [Link]
= age def bark(self): return f"{[Link]} says: Woof!" def info(self): return
f"{[Link]} is a {[Link]}-year-old {[Link]}" def birthday(self): [Link] +=
1 return f"Happy birthday {[Link]}! Now {[Link]}." # Create instances rex =
Dog("Rex", "German Shepherd", 3) bella = Dog("Bella", "Labrador", 5)
print([Link]()) # Rex says: Woof! print([Link]()) # Bella is a 5-year-old
Labrador print([Link]()) # Happy birthday Rex! Now 4.
Inheritance
A child class inherits all methods from a parent class and can add/override them.
class Animal: def __init__(self, name): [Link] = name def speak(self): return
"..." class Cat(Animal): # Cat inherits from Animal def speak(self): return
f"{[Link]} says: Meow!" class Dog(Animal): def speak(self): return f"{[Link]}
says: Woof!" animals = [Cat("Whiskers"), Dog("Rex"), Cat("Luna")] for a in animals:
print([Link]())
Day 13 Exercises
✓ BankAccount class: balance, deposit(amount), withdraw(amount), get_balance()
✓ Rectangle class: width, height, area(), perimeter(), is_square()
✓ Student class: name, grades list, add_grade(), average(), letter_grade()
✓ Inherit from Animal to make Cat, Dog, Bird each with their own speak() method
DAY 14
Final Project & Next Steps
■ You've made it to Day 14! Today you build your capstone project and plan the road ahead.
Final Project: Personal Expense Tracker
Required Features
• Add expenses (amount, category, description)
• View all expenses, sorted by date
• Show total spending and spending by category
• Save expenses to a JSON file — persistent between runs
• Load existing expenses on startup
• Filter expenses by category
Suggested Structure
import json, datetime class Expense: def __init__(self, amount, category,
description): [Link] = amount [Link] = category [Link] =
description [Link] = [Link]().isoformat() def to_dict(self): return
{"amount": [Link], "category": [Link], "description": [Link],
"date": [Link]} class ExpenseTracker: def __init__(self,
filename="[Link]"): [Link] = filename [Link] = [Link]() def
add(self, amount, category, description): e = Expense(amount, category, description)
[Link](e.to_dict()) [Link]() def total(self): return
sum(e["amount"] for e in [Link]) def by_category(self): cats = {} for e in
[Link]: cats[e["category"]] = [Link](e["category"], 0) + e["amount"] return
cats def save(self): with open([Link], "w") as f: [Link]([Link], f,
indent=2) def load(self): try: with open([Link]) as f: return [Link](f)
except FileNotFoundError: return []
Concepts Used in Final Project
✓ Classes & OOP (Day 13) — Expense and ExpenseTracker classes
✓ JSON file I/O (Day 12) — Persistent storage
✓ Error handling (Day 11) — FileNotFoundError on first run
✓ Dictionaries (Day 9) — Category totals
✓ Functions (Day 8) — Every action as a method
✓ Loops & lists (Days 5-6) — Processing all expenses
✓ User input & conditionals (Days 3-4) — Interactive menu
What You've Learned in 14 Days
Week 1 Concepts Week 2 Concepts
✓ Python setup & environment ✓ Functions & return values
✓ Variables & data types ✓ Dictionaries & sets
✓ String manipulation ✓ File reading & writing
✓ User input ✓ Error handling
✓ if/elif/else logic ✓ Standard library modules
✓ for & while loops ✓ OOP basics
✓ Lists & comprehensions ✓ JSON data persistence
Your Next Steps
Path Topics Resources
Web Dev HTML/CSS + Flask or Django Flask docs, CS50W
Data Science pandas, matplotlib, numpy Kaggle Learn (free)
Automation selenium, requests, BeautifulSoup Automate the Boring Stuff (free book)
Game Dev pygame, arcade library Real Python tutorials
AI/ML scikit-learn, TensorFlow basics [Link] (free course)
Free Resources to Continue Learning
• [Link]/doc — Official Python documentation
• [Link] — In-depth tutorials for every level
• [Link] — Practice problems to sharpen your skills
• [Link] — Share your projects and learn from others
• [Link] — Your go-to for every coding question
You are now a Python programmer. Keep building, keep breaking things, and keep
learning. Every expert started exactly where you did on Day 1. ■