Part 1 of 5

Welcome to Python in Practice

From knowing the words to speaking the language

Course 1 gave you the vocabulary of Python: variables, types, if/elif/else, for loops, lists, functions, and a first taste of comprehensions. You can read a short program and understand every line.

This course is about fluency — the difference between knowing words and holding a conversation. Real programs rarely use one concept at a time. They parse messy text, keep several collections in sync, handle bad input without crashing, and organize logic into functions that other functions call. That's what "in practice" means, and it's what you'll build here.

A quick tour of what's ahead:

  • Strings in depth — slicing, the method toolbox, split/join, and precise output formatting
  • Tuples and unpacking — fixed-shape records, enumerate, and zip
  • Dictionaries and sets — the workhorses of real Python
  • Comprehensions, advanced functions, and scope — writing code that reads like the problem
  • Errors, generators, and classes — handling failure gracefully and modeling your own types
  • Files, JSON, and type hints — talking to the world outside your program
  • A capstone project that puts all of it together

Expect each lesson to take 20 to 40 minutes. The exercises start friendly and end genuinely hard — that's deliberate. Three habits will carry you through:

  1. Read error messages. They are not noise; they tell you the file, the line, and what went wrong. We train this skill first, in the very next section.
  2. Experiment. If you wonder "what happens if...", don't guess — change the code and run it. The interpreter is free and never annoyed.
  3. Ask the tutor. Stuck for more than a few minutes? Ask. Explaining what you expected versus what happened often solves the problem by itself.

Let's shake off the rust with a warm-up.

Use a for loop with range() and an f-string to print the squares of 1 through 5, one per line. Expected output, exactly:

1 squared is 1
2 squared is 4
3 squared is 9
4 squared is 16
5 squared is 25
Python
ChecksPrints all five lines exactlyUses a loop rather than five print statements

The tutor sees your code and your last run