Python Quest

Learning map · Track 2 · beginner

Variables, Data Types and Operators

Every useful program keeps track of something: a price, a customer's name, a running total, whether an order has shipped. This track teaches you how Python stores those values in variables and what kinds of values exist. You will work with whole numbers and decimals, find out why 0.1 + 0.2 is not exactly 0.3 and how to round money correctly, slice and clean up text, build neatly aligned reports with f-strings, compare values to get True or False, and convert between types without your program crashing.

It is written for learners who have finished Getting Started with Python and can already run a program, use print() and read a line with input(). Every lesson is built around small, realistic tasks — receipts, invoices, payroll, stock counts, survey answers — and every exercise is checked automatically by running your code. The track ends with a guided mini project: a restaurant bill splitter that reads the bill, adds tax and tip, and prints a clean per-person summary.

By the end of this track you can

  • Create, reassign and swap variables, and choose clear names that follow Python conventions
  • Calculate with integers and floats using //, %, ** and augmented assignment, respecting operator precedence
  • Explain floating-point rounding errors and round or format money values correctly
  • Index, slice, clean and format text with string methods and f-string format specifications
  • Compare values to produce booleans and convert safely between str, int, float and bool
  • Read, clean and convert user input, including several values on one line, into a working program

Lessons

  1. 1Variables and assignmentStore values under names, change them as a program runs, assign several at once and swap two values safely.25 min · 4 exFree
  2. 2Naming and readabilityFollow Python's naming rules, write names in snake_case, mark constants in UPPER_CASE and choose names that explain the code.25 min · 3 exFree
  3. 3Integers, floats and operatorsCalculate with whole numbers and decimals using +, -, *, /, //, % and **, follow operator precedence and update variables with augmented assignment.35 min · 5 exFree
  4. 4Float precision and roundingWhy 0.1 + 0.2 is not exactly 0.3, how round() really behaves, and how to show money with exactly two decimals.30 min · 4 exFree
  5. 5Strings as dataTreat text as data: pick out characters by index, cut out pieces with slices, measure with len() and clean up with string methods.35 min · 4 exFree
  6. 6f-strings and formattingBuild readable output with f-strings and format specifications: fixed decimals, thousands separators, percentages, padding and aligned columns.35 min · 4 exFree
  7. 7Booleans and comparisonsAsk yes-or-no questions about your data with comparison operators and store the answers as True or False.30 min · 4 exFree
  8. 8Converting between typesTurn text into numbers and numbers into text with int(), float(), str() and bool(), and understand why some conversions fail.35 min · 4 exFree
  9. 9Processing user inputRead what a user types, clean it up, convert it, and split one line into several values.35 min · 4 exFree
  10. 10None and dynamic typingUse None for a value that is missing, see how variable names refer to objects, and check types with type() and isinstance().30 min · 4 exFree
  11. 11Mini project: restaurant bill splitterBuild a restaurant bill splitter step by step: read dish prices, add VAT and a tip, split the total fairly and print an aligned summary.50 min · 5 exFree