Track · Learn Python

Python projects for beginners: learn Python level by level

The labs of Python, Level by Level. You run the till at Bean There, a small café, and every lab is one job on it: print a receipt to the penny, take the order, apply the discount rulebook, count the stock down and report the Friday rush. Python runs in your browser, so there is nothing to install.

15
Labs
7 h
In total
Beginner
Level
5
Free
Start the free labFirst Day at Bean There: Your First Python Script · 25 min

What you will build

  • Scripts that keep money exact: whole pennies, pounds and pence, and columns that line up
  • Programs that ask questions, turn the answers into numbers and survive a typo
  • Decisions with if, elif, else, and, or and match, applied in the right order
  • Loops with while and for that count, total, stop early and skip what they should
  • Three boss programs checked against cases you can't see, the way real code is tested

Before you start

  • None. Level 1 starts from your first print()
  • A browser: Python runs in it, so there is nothing to install

Tools you will use

Pythonf-stringsinputif and matchwhile and forrangerandom

Labs in this track

In order, from the first lab to the hardest. Every lab stands on its own, so start wherever you like.

1

Level 1: First day

print, variables, numbers, text, input and reading an error, then the boss: an exact receipt for every customer on opening morning.

  1. # py-l1-first-script · step 1
    $ lab.check(1)
    Step 1 Complete
    grade ........... pass
    Lab 1First Day at Bean There: Your First Python ScriptYour first hour as the café's developer: run your first Python script, then greet customers, put today's special on the board, tidy names for cup labels and add up the morning's sales, one Python idea per step.25 minBeginnerHostedFree
  2. # py-l1-receipt · step 1
    $ lab.check(1)
    Step 1 Complete
    grade ........... pass
    Lab 2The Receipt: Money in Whole PenniesMake Bean There's till print a receipt Sam can hand over without checking it: prices in whole pennies, pounds and pence with // and %, the zero in £3.05, and columns that line up, one idea per step.30 minBeginnerHostedFree
  3. # py-l1-ask-the-customer · step 1
    $ lab.check(1)
    Step 1 Complete
    grade ........... pass
    Lab 3Ask the Customer: input() and Numbers That Arrive as TextBean There's till stops using fixed numbers and asks the customer: input() for the name and the order, int() and float() for numbers that arrive as text, a price typed in pounds turned into exact pennies, and names tidied however people type them.25 minBeginnerHostedFree
  4. # py-l1-read-the-error · step 1
    $ lab.check(1)
    Step 1 Complete
    grade ........... pass
    Lab 4Read the Error: Fix Five Broken Scripts from Their TracebacksFive of Bean There's scripts crash before opening. Read each traceback from the bottom up, find the line it points at and fix it: a NameError, a SyntaxError, a TypeError, an IndentationError and a script with two bugs in a row.25 minBeginnerHostedFree
  5. # py-l1-boss-opening-morning · step 1
    $ lab.check(1)
    Step 1 Complete
    grade ........... pass
    Lab 5Boss: Opening MorningLevel 1's boss. Doors open at 8:00 and the till has to take every order and print an exact receipt: names typed any way, hidden orders, then a new item and new prices halfway through the morning. Everything from Level 1 at once: input, variables, whole-penny money, string methods and f-strings.35 minBeginnerHostedFree
2

Level 2: Decisions

True and False, if, elif and else, and, or, not and match, then the boss: a discount rulebook whose rules overlap.

  1. # py-l2-happy-hour · step 1
    $ lab.check(1)
    Step 1 Complete
    grade ........... pass
    Lab 6Happy Hour: True, False and ifBean There's flat whites cost less from 3pm to 5pm. Teach the till to tell: comparisons that give True or False, if and else, elif for the time of day, or for members, and a closed sign that comes first.25 minBeginnerHostedPro
  2. # py-l2-loyalty-stamps · step 1
    $ lab.check(1)
    Step 1 Complete
    grade ........... pass
    Lab 7Loyalty Stamps: Decisions with NumbersBean There's stamp card: one stamp per coffee and every tenth coffee free. The till decides when a free coffee is due, says how many stamps to go in good English, handles a big order that earns two at once and turns away answers that aren't numbers.25 minBeginnerHostedPro
  3. Lab 8Opening Hours: and, or and Decisions Inside DecisionsThe sign on Bean There's door: weekday and weekend hours, the right closed message before opening and after closing, tomorrow's opening time, and Sam's note when there is one. Conditions joined with or and and, if inside if, and truthiness.30 minBeginnerHostedPro
  4. Lab 9Drink Sizes: match and casePrice Bean There's flat whites by size and milk with match: a case per size, short answers with |, a case _ for anything else, answers typed any way, and a second match for the milk.25 minBeginnerHostedPro
  5. Lab 10Boss: The Discount RulebookLevel 2's boss. Sam's discounts overlap: happy hour, a free cup on big orders, member and student cards, Monday mornings and a floor under every price. Apply the rulebook in order and print the right total for customers you can't see, then again after the prices change.40 minBeginnerHostedPro
3

Level 3: Loops

while, for and range, break and continue, counters and running totals, then the boss: a whole Friday of orders, hour by hour.

  1. Lab 11The Order Queue: while LoopsBean There's morning queue, one customer at a time: a while loop that counts down, a till that takes orders until you type done, break when the milk runs out, continue for a cancelled order, and a loop that never ends, fixed.30 minBeginnerHostedPro
  2. Lab 12The Guessing Game: random and Loops That CountSam's counter game: guess how many beans are in the jar. Pick a random number, loop until the guess is right with higher and lower hints, count the guesses, stop after seven, and say when a guess is close.25 minBeginnerHostedPro
  3. Lab 13Stock Countdown: for Loops and rangeThe croissant sheet for Bean There: walk through the opening hours with for and range, count the stock down as it sells, stop when it sells out, skip the training hour and count down the oven timer.25 minBeginnerHostedPro
  4. Lab 14The Price Table: Nested LoopsA price table for Bean There's wall: what 1 to 5 of each item costs, in lined-up columns. Print a row with end, add a header, loop over every item with a loop inside a loop, take the office deal off and make the table any size.30 minBeginnerHostedPro
  5. Lab 15Boss: The Friday RushLevel 3's boss. A whole Friday of orders comes in one at a time: the till counts them until closing, reports every hour that had orders, finds the busiest one and keeps working when the prices change, for days you can't see.40 minBeginnerHostedPro

Guides for this track

Questions about this track

Other tracks

Every lab with Pro

This track and every other one, plus every practice test. $29.99 a month, cancel any time.

See Pro