Code24Lab
Python Beginner

Python Foundations: Variables, Loops, Functions & Files

Learn Python by thinking like the interpreter: trace variables, strings, lists, loops, dictionaries, functions, files and error handling for a fictional bike rental, with every answer checked as you go.

20 lessons 20 labs Certificate

  • One-time payment
  • Instant access right after payment
  • Secure checkout with Stripe

About this course

In this beginner course you learn Python by thinking like the interpreter. Each of the 20 labs shows a short script for a fictional bike rental next to its data, and you work out what the code produces: variable values, string slices, list changes, loop traces, dictionary counts, function return values, file contents and the result of try/except. Every answer is a formula that is checked instantly, also with changed data, so guessing does not work. You meet the classic beginner traps, such as floor division with negatives, off-by-one loop conditions and functions without return, and finish with a daily report project and a certificate exam.

Lessons

  1. Your First Script: Variables, Arithmetic and print()LabFree
  2. Numbers: int, float, //, % and **Lab Locked
  3. Types and Conversion: str, int, float and type()Lab Locked
  4. Strings I: Indexing, Slicing and len()Lab Locked
  5. Strings II: Methods, split() and f-stringsLab Locked
  6. Comparisons and Booleans: and, or, notLab Locked
  7. Decisions: if, elif and elseLab Locked
  8. Lists: Index, Slice, append(), pop() and insert()Lab Locked
  9. for Loops and range()Lab Locked
  10. while Loops: Repeat Until a Condition FailsLab Locked
  11. Loop Patterns: Counters, Accumulators, break and continueLab Locked
  12. Dictionaries: Counting and Summing by KeyLab Locked
  13. Sets, Tuples and MembershipLab Locked
  14. Functions: def, Parameters, Defaults and returnLab Locked
  15. Functions II: Composition, Return Values and ScopeLab Locked
  16. Built-in Helpers: sum, max, sorted, zip and enumerateLab Locked
  17. Reading Files: open(), with and Parsing LinesLab Locked
  18. Writing Files: write(), Modes "w" and "a", and NewlinesLab Locked
  19. Handling Errors: try, except and Clean InputLab Locked
  20. Final Project: The Daily Rental ReportLab Locked