Programming Books

Python Full Course: Beginner to Advanced | Complete Notes, Roadmap & Free PDF

python beginner to advanced pdf Advanced 2026 - Techprofree

Complete free Python course in one page: 12 structured modules with tested code and real output, a stage-by-stage roadmap, an 80-topic checklist, three practice projects, the five errors every beginner hits (with the exact messages), and our downloadable notes PDF — plus the best genuinely free Python books, legally linked. One honest line before we start: we don’t host paid courses or pirated books here; everything linked is officially free from its author or publisher.

Bookmark this page — it’s built to be your home base from your first print() to your first real project. Every code block below was executed before publishing; the output you see is the output you’ll get.

The Python Roadmap — Beginner → Intermediate → Advanced

Stage Modules Time (1 hr/day) By the end you can…
🟢 Beginner 1–6: setup, variables, conditions, loops, strings, data structures 3–4 weeks Build calculators, quizzes, number games; read any basic script
🟡 Intermediate 7–9 + checklist level 2: functions, files, errors, modules 3–4 weeks Build tools that save data, survive bad input, and use libraries
🔵 Advanced-ready 10–12: OOP, pip ecosystem, comprehensions → generators → decorators 4–6 weeks Read framework code, structure real projects, start data science or web
The only rule that matters: type every example yourself (no copy-paste), break it on purpose, fix it. Ten typed-and-broken programs teach more than a hundred watched tutorials — that’s not motivation talk, it’s how programming memory works.
python beginner to advanced pdf Python roadmap from beginner to advanced - 3 stages with weekly plan

The 3-stage Python roadmap — save it, follow it.

Complete Python Topics Checklist (Save This)

Everything Python-core in one list — tick topics off as you learn them. This checklist is also inside the PDF at the end, print-ready.

🟢 Beginner — the foundation (25 topics)

  • Installing Python & PATH
  • Running .py files / IDLE / VS Code
  • print() & comments
  • Variables & naming rules
  • Data types: int, float, str, bool
  • Type conversion (int, str, float)
  • input() — and why it returns str
  • f-strings & string formatting
  • Arithmetic operators (+ − * / // % **)
  • Comparison operators (== != > <)
  • Logical operators (and, or, not)
  • if / elif / else
  • Nested conditions
  • for loops & range()
  • while loops
  • break & continue
  • String methods (upper, strip, replace, split)
  • String slicing [start:end:step]
  • Lists: create, index, append, remove
  • List slicing
  • Tuples & unpacking
  • Sets & uniqueness
  • Dictionaries: keys, values, get()
  • Looping over dicts & lists
  • len(), min(), max(), sum()

🟡 Intermediate — real programs (24 topics)

  • Functions: def, return
  • Parameters, defaults, keyword args
  • *args & **kwargs
  • Variable scope (local vs global)
  • List comprehensions
  • Dict & set comprehensions
  • lambda functions
  • map(), filter(), sorted(key=…)
  • File handling: open modes w/r/a
  • with statement (context managers)
  • Working with CSV files
  • try / except / else / finally
  • Raising exceptions (raise)
  • Common exceptions (ValueError, TypeError, KeyError)
  • Modules & import styles
  • Standard library tour: math, random, datetime, os
  • pip & installing packages
  • Virtual environments (venv)
  • requests basics (calling an API)
  • JSON: loads & dumps
  • String ↔ date conversion (strftime/strptime)
  • Enumerate & zip
  • Ternary expressions
  • Docstrings & help()

🔵 Advanced-ready — professional Python (24 topics)

  • OOP: classes & objects
  • __init__ & self
  • Instance vs class attributes
  • Methods & method overriding
  • Inheritance & super()
  • Polymorphism
  • Dunder methods (__str__, __len__)
  • Generators & yield
  • Iterators & iter()/next()
  • Decorators
  • Closures
  • Type hints (def f(x: int) -> str)
  • Regular expressions (re)
  • Working with paths (pathlib)
  • Error logging (logging module)
  • Unit testing basics (unittest / pytest)
  • Reading large files efficiently
  • Date/time arithmetic (timedelta)
  • Collections module (Counter, defaultdict)
  • Itertools essentials
  • Basic SQLite with sqlite3
  • Structuring a project (folders, __main__)
  • Reading documentation effectively
  • Next steps: pandas / Flask / automation
Complete Python topics checklist - 73 topics from beginner to advanced

The full 73-topic checklist — also inside the free PDF, print-ready.

The 12 Modules — Notes, Code & Real Output

Each module: the concept in plain words, a short program, its actual output, and one practice task. Run everything — reading is 20%, typing is 80%.

Module 1: Setup & Your First Program

Install Python from python.org (tick “Add to PATH” on Windows), open any editor — IDLE, VS Code, or even your phone’s Pydroid — and run your first line. If this prints, your setup works and everything below is open to you.

CODE — RUN THISprint(“Hello, TechProFree!”)
print(“Python version check done – you are ready.”)
OUTPUT (REAL — WE RAN IT)Hello, TechProFree!
Python version check done – you are ready.

✏️ Practice: change the message, run it again — you just edited a program.

Module 2: Variables, Data Types & Input

Variables are labeled boxes for data. Python figures out the type itself — string, integer, float, boolean — and f"..." strings let you drop variables straight into text. One trap to tattoo on your brain: input() always returns a string, even when the user types a number.

CODE — RUN THISname = “Ahmed”
age = 21
height = 5.6
is_student = True

print(type(name), type(age), type(height), type(is_student))
print(f”{name} is {age} years old.”)

# input() always returns a string!
# age = input(“Your age: “) -> “21” (str), convert: int(age)

OUTPUT (REAL — WE RAN IT)<class ‘str’> <class ‘int’> <class ‘float’> <class ‘bool’>
Ahmed is 21 years old.

✏️ Practice: take a friend’s name and birth year with input(), print their age (convert with int() first).

Module 3: Operators & If/Else Decisions

Programs become useful when they decide. if / elif / else walks conditions top to bottom and runs the first true branch. Alongside: // floor-divides, % gives the remainder, ** is power — three operators beginners meet in every exercise.

CODE — RUN THISmarks = 78

if marks >= 80:
grade = “A”
elif marks >= 70:
grade = “B”
elif marks >= 60:
grade = “C”
else:
grade = “F”

print(“Marks:”, marks, “| Grade:”, grade)
print(10 // 3, 10 % 3, 2 ** 5) # floor div, remainder, power

OUTPUT (REAL — WE RAN IT)Marks: 78 | Grade: B
3 1 32

✏️ Practice: write a grading program for YOUR marks scheme, add an A+ branch.

Module 4: Loops — for & while

Loops repeat work so you don’t. for i in range(1, 6) counts 1 to 5 (range stops BEFORE the end number — remember this), while while repeats until its condition turns false. Every table, menu, and game loop you’ll ever write starts here.

CODE — RUN THIS# for loop with range
for i in range(1, 6):
print(f”5 x {i} = {5*i}”)

# while loop
count = 3
while count > 0:
print(“Countdown:”, count)
count -= 1
print(“Done!”)

OUTPUT (REAL — WE RAN IT)5 x 1 = 5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
Countdown: 3
Countdown: 2
Countdown: 1
Done!

✏️ Practice: print the 7-times table, then a countdown from 10 that says “Liftoff!” at the end.

Module 5: Strings in Depth

Text is data you can operate on: change case, replace words, measure, slice pieces out with [start:end], and check membership with in. Strings are everywhere — user input, files, web data — so these few methods pay rent daily.

CODE — RUN THIStext = “python is easy”

print(text.upper())
print(text.title())
print(text.replace(“easy”, “powerful”))
print(len(text), “characters”)
print(text[0:6]) # slicing
print(“easy” in text) # membership

OUTPUT (REAL — WE RAN IT)PYTHON IS EASY
Python Is Easy
python is powerful
14 characters
python
True

✏️ Practice: take a sentence and print it reversed (hint: slicing accepts a step — try [::-1]).

Module 6: Lists, Tuples, Sets & Dictionaries

Python’s four containers, one line each: list = ordered and changeable, tuple = fixed, set = automatic no-duplicates, dict = key→value lookups. Choosing the right one is half of clean Python — and dicts run the modern world (every API response is basically one).

CODE — RUN THISfruits = [“apple”, “mango”, “banana”] # list – ordered, changeable
point = (3, 5) # tuple – fixed
unique = {1, 2, 2, 3, 3} # set – no duplicates
student = {“name”: “Sara”, “marks”: 88} # dict – key:value

fruits.append(“orange”)
print(fruits)
print(point[0], point[1])
print(unique)
print(student[“name”], “scored”, student[“marks”])

OUTPUT (REAL — WE RAN IT)[‘apple’, ‘mango’, ‘banana’, ‘orange’]3 5
{1, 2, 3}
Sara scored 88

✏️ Practice: build a dict for yourself (name, city, 3 skills as a list inside it) and print each part.

Module 7: Functions

Functions bundle logic behind a name: define once with def, reuse forever. Parameters make them flexible, return hands the result back, and default values (like lang="en") make arguments optional. If you copy-paste code, you needed a function.

CODE — RUN THISdef greet(name, lang=”en”):
if lang == “ur”:
return f”Salaam, {name}!”
return f”Hello, {name}!”

def area(length, width):
return length * width

print(greet(“Ali”))
print(greet(“Ali”, lang=”ur”))
print(“Area:”, area(5, 3))

OUTPUT (REAL — WE RAN IT)Hello, Ali!
Salaam, Ali!
Area: 15

✏️ Practice: write bmi(weight_kg, height_m) that returns the BMI rounded to 1 decimal.

Module 8: File Handling

Programs that forget everything on exit are toys. with open(...) reads and writes files AND closes them automatically even if errors hit — which is why it’s the only pattern worth learning. Mode “w” writes (overwrites!), “a” appends, “r” reads.

CODE — RUN THIS# write then read a file
with open(“notes.txt”, “w”) as f:
f.write(“Line 1: Python file handling\n”)
f.write(“Line 2: with open() auto-closes the file\n”)

with open(“notes.txt”, “r”) as f:
for line in f:
print(line.strip())

OUTPUT (REAL — WE RAN IT)Line 1: Python file handling
Line 2: with open() auto-closes the file

✏️ Practice: save 3 of your goals to goals.txt, then read and print them numbered.

Module 9: Error Handling — try/except

Users type nonsense and files go missing; try/except is how programs survive reality. Catch the SPECIFIC error you expect (here ZeroDivisionError), handle it gracefully, and use finally for cleanup that must always run.

CODE — RUN THISdef safe_divide(a, b):
try:
return a / b
except ZeroDivisionError:
return “Cannot divide by zero!”
finally:
print(f” (attempted {a} / {b})”)

print(safe_divide(10, 2))
print(safe_divide(5, 0))

OUTPUT (REAL — WE RAN IT)(attempted 10 / 2)
5.0
(attempted 5 / 0)
Cannot divide by zero!

✏️ Practice: wrap int(input()) in try/except so letters don’t crash your program — loop until valid.

Module 10: OOP — Classes & Inheritance

Classes are blueprints that bundle data (via __init__) with behavior (methods). Cat(Animal) inherits everything from Animal and overrides what it changes — watch the same speak() call produce different results per object. That’s polymorphism, and it’s the backbone of frameworks you’ll meet later.

CODE — RUN THISclass Animal:
def __init__(self, name):
self.name = name
def speak(self):
return f”{self.name} makes a sound”

class Cat(Animal): # inheritance
def speak(self): # method overriding
return f”{self.name} says Meow”

pets = [Animal(“Rex”), Cat(“Milo”)]for p in pets:
print(p.speak())

OUTPUT (REAL — WE RAN IT)Rex makes a sound
Milo says Meow

✏️ Practice: add a Dog class that says Woof, and give Animal an age that prints in speak().

Module 11: Modules, the Standard Library & pip

Python ships with batteries: math, random, datetime and 200+ more modules, one import away. Beyond that, pip install package-name opens 500,000+ community packages — requests for web, pandas for data. Professionals assemble more than they build from scratch.

CODE — RUN THISimport math
import random
from datetime import date

print(“Square root of 144:”, math.sqrt(144))
print(“Random pick:”, random.choice([“red”, “green”, “blue”]))
print(“Today is:”, date.today().strftime(“%d %B %Y”))

# Third-party packages install with pip:
# pip install requests

OUTPUT (REAL — WE RAN IT)Square root of 144: 12.0
Random pick: blue
Today is: 15 November 2026

✏️ Practice: use random to build a dice roller that rolls two dice and prints the total.

Module 12: Intermediate Powers — Comprehensions, Lambda, Generators, Decorators

The four features that make Python read like Python: comprehensions build lists in one line, lambda writes tiny throwaway functions (perfect as sort keys), generators produce values lazily with yield (memory-friendly for huge sequences), and decorators wrap extra behavior around functions with one @line. Master these and intermediate code stops looking like magic.

CODE — RUN THIS# List comprehension
squares = [n**2 for n in range(1, 6)]print(“Squares:”, squares)

# Lambda + sorted
students = [(“Ali”, 85), (“Sara”, 92), (“Bilal”, 78)]top = sorted(students, key=lambda s: s[1], reverse=True)
print(“Topper:”, top[0])

# Generator – memory-friendly sequences
def countdown(n):
while n > 0:
yield n
n -= 1
print(“Generator:”, list(countdown(5)))

# Decorator – wrap extra behavior around a function
def shout(func):
def wrapper():
return func().upper() + “!”
return wrapper

@shout
def hello():
return “hello from techprofree”
print(hello())

OUTPUT (REAL — WE RAN IT)Squares: [1, 4, 9, 16, 25]Topper: (‘Sara’, 92)
Generator: [5, 4, 3, 2, 1]HELLO FROM TECHPROFREE!

✏️ Practice: write a comprehension for even numbers 1–20, then sort a list of (product, price) tuples by price with lambda.

Real Python code output examples from the 12 modules

Real outputs from the modules above — every example executed before publishing.

Mini Projects — Prove the Modules

  • 🎲 Number Guessing Game (modules 2–4, 9): random number, limited attempts, hints — the classic first project. Full tutorial with code →
  • 🧮 Calculator with Error Handling (modules 3, 7, 9): menu loop, functions per operation, try/except so letters and ÷0 don’t crash it. Full tutorial with code →
  • 📝 To-Do CLI with File Save (modules 6, 8): add/view/delete tasks stored in a text file — your first program with memory. Build it from modules 6+8 above, then explore 145 more projects by level →

Mistakes Every Beginner Makes (With the Exact Errors)

1. The missing indent

BROKENif True:
print(“hi”)
REAL ERROR print(“hi”)
^
IndentationError: expected an indented block after ‘if’ statement on line 1

Python’s blocks are made of spaces. Everything inside an if, loop, or function must be indented (4 spaces, consistently).

2. = vs ==

BROKENx = 5
if x = 5:
print(“yes”)
REAL ERROR if x = 5:
^^^^^
SyntaxError: invalid syntax. Maybe you meant ‘==’ or ‘:=’ instead of ‘=’?

One = assigns, two == compares — Python even suggests the fix now. You’ll still do it; everyone does.

3. input() returns a string

BROKENage = “21” # what input() returns
print(age + 5)
REAL ERRORTraceback (most recent call last):
File “<string>”, line 2, in <module>
TypeError: can only concatenate str (not “int”) to str

Convert before math: age = int(input("Age: ")). This single line fixes the most common beginner crash in existence.

4. The mutable default argument trap

LOOKS FINE, ISN’Tdef add_item(item, bag=[]): # danger: mutable default
bag.append(item)
return bag

print(add_item(“pen”))
print(add_item(“book”)) # expected [“book”], but…

REAL OUTPUT — THE BAG IS SHARED![‘pen’][‘pen’, ‘book’]

Default values are created ONCE — a default list is shared across all calls. The fix: default to None, create the list inside the function.

5. Off-by-one with range()

REMEMBER# range(5) gives 0..4 – the classic off-by-one
print(list(range(5)))
print(list(range(1, 6))) # when you want 1..5
REAL OUTPUT[0, 1, 2, 3, 4][1, 2, 3, 4, 5]

range(n) starts at 0 and stops BEFORE n. Want 1 to 5? range(1, 6). This one mistake causes half of all “my loop runs the wrong number of times” questions.

Where to Practice (Free Websites)

Site Best for Start at…
PracticePython.org Beginner exercises matched to modules 1–9, with solutions Exercise 1, after module 4
HackerRank Structured Python track with instant checking “Python (Basic)” after module 6
Exercism Real feedback from human mentors, free After module 7 (functions)
Codewars Game-like challenges (8 kyu = easiest) 8 kyu katas, after module 7
LeetCode (Easy) Interview-style problems — later, not first Easy tier, after module 12
W3Schools Try-It Quick in-browser drills, zero setup Anytime — even on mobile

How to Learn Python Faster (What Actually Works)

  • The 20/80 rule: 20% reading, 80% typing. Every module above has a practice line for exactly this reason — the modules you type are the modules you keep.
  • Break things on purpose: after each working example, change something and predict the result before running. Wrong predictions are where learning happens.
  • One project per stage: finish beginner → build the guessing game. Finish intermediate → the to-do CLI. Projects convert “I watched it” into “I can do it.”
  • Read errors top to bottom: the last line names the error type, the arrow shows where. The mistakes section above trains this — error messages are instructions, not insults.
  • Daily beats weekend: 1 focused hour daily outperforms a 7-hour Sunday. Programming memory consolidates with sleep between sessions.
  • Use AI as a tutor, not a typist: ask it to explain, quiz you, and review your code — not to write your practice tasks. (Ready for more? Build your own AI agent in Python once you finish module 12.)

Best Free Python Books (Legally Free — Official Links)

Every link below goes to the author’s or publisher’s own site, where the book is intentionally free. No mirrors, no “free download” of paid books — if a book is paid (like Python Crash Course, which is excellent), buy it from the publisher; we don’t link pirated copies.

Book Level Why this one Official link
Python for Everybody (PY4E) Beginner The gentlest start; Creative Commons; free PDF + videos py4e.com/book
Automate the Boring Stuff Beginner–Inter. Learn by automating real tasks; free to read online (buy to support) automatetheboringstuff.com
Think Python (2e) Beginner–Inter. Teaches you to THINK like a programmer; free PDF greenteapress.com
A Byte of Python Beginner Short, friendly, many languages incl. simple English python.swaroopch.com
Python Notes for Professionals Intermediate Massive free reference PDF compiled from community docs goalkicker.com
Dive Into Python 3 Intermediate For those who already program; sharp and free diveintopython3.net
Official Python Tutorial All levels The source of truth, always current docs.python.org

What to Learn After Python

📥 Download the Free PDF — Python Beginner to Advanced Notes

Python Beginner to Advanced Notes — TechProFree Edition

All 12 modules · 80-topic checklist · mistakes reference · roadmap — print-friendly, 100% free, made by us (not a pirated book)

Download the Free PDF Notes →

Type it. Break it. Fix it. That’s the whole secret. 🐍

Next stop: pick your first project from the 145-project roadmap.

Browse 145 Python Projects →

Frequently Asked Questions

How long does it take to learn Python from beginner to advanced?

With one focused hour daily: the beginner stage takes 3–4 weeks, intermediate another 3–4, and advanced-ready concepts 4–6 more — roughly 3 months to genuine competence. Typing and breaking every example (not just reading) is what keeps you on that schedule.

Where can I get a Python beginner to advanced PDF for free?

Right on this page — our own TechProFree notes PDF covers all 12 modules, the 80-topic checklist and the mistakes reference, free with no catch. For full free books, the table above links seven that are legally free from their authors, including Python for Everybody and Think Python.

Should I learn Python 2 or Python 3?

Python 3, without exception — Python 2 reached end-of-life in 2020 and nothing new uses it. Every example on this page is Python 3 and was executed on a current version before publishing.

What is the best roadmap for learning Python?

Foundation first (variables → conditions → loops → data structures), then program-building skills (functions, files, error handling), then professional patterns (OOP, libraries, comprehensions/generators/decorators) — exactly the 12-module order above, with a project after each stage to lock it in.

Is learning Python enough to get a job?

Core Python is the entry ticket, not the whole fare. Pair it with a direction — data analysis (pandas), web (Flask/Django), or automation — plus 3–5 real projects you can explain line by line. The ‘what to learn after’ section maps those paths.

Can I download paid Python books or courses here?

No — we don’t host or link pirated copies of paid books like Python Crash Course. Everything downloadable here is either our own original notes or an official free release linked straight from the author or publisher.