Lab, Operators and Control Flow
7 tasks, easy to hard: Predict, then run, Write it, Complete it, Fix it, Trace it, Refactor it, Mini challenge. Hints come one at a time and you can see each answer. Lab work is saved as practice and earns no XP.
Open the lessonYou can read every task below. Running, checking and saving them needs a free ID.
7 tasks
Task 01 .Type what the program will print, then run it to compare.
Type exactly what this program prints.
Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and save your practice. Practice does not award XP.
Task 02 .Solve it from the prompt, starting from an empty editor.
The variable number is 14. Use an if-else statement to print 14 is even or 14 is odd, with the number taken from the variable.
Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and save your practice. Practice does not award XP.
Task 03 .Fill the marked gaps in the starter code.
Children under 12 pay 5, people 65 or over pay 6, and everyone else pays 10. Replace each ___ so the program prints Price: 6 for age 70.
Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and save your practice. Practice does not award XP.
Task 04 .The starter code has a bug. Repair it so the checks pass.
This program should print Merit for a score of 75, but the conditions are in the wrong order and one line is missing its colon. Fix both.
Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and save your practice. Practice does not award XP.
Task 05 .Fill the table with the variable values, step by step.
Each row shows points and level each time either changes, once both exist. Follow which branches run.
points = 30
level = "bronze"
if points >= 25:
level = "silver"
points = points + 10
if points >= 40:
level = "gold"
elif points >= 35:
points = points * 2Sign in or create a free ID to fill in and check this table.
Task 06 .Rewrite working code to the stated rule, keeping the same output. Rule: Assign status with one conditional expression instead of an if statement.
This if-else only picks one of two words. Rewrite it as a single line using a conditional expression (... if ... else ...). The output must stay Status: open.
Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and save your practice. Practice does not award XP.
Task 07 .A short task that combines this lesson with earlier ones.
A car park is free for up to 30 minutes, costs 2 per started hour after that, and is capped at 10 per day. Blue badge holders always park free. Set minutes = 200 and blue_badge = False and print Fee: 8. Use // to count started hours: 200 minutes is 4 started hours.
Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and save your practice. Practice does not award XP.