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 total_minutes is 200. Print 3 hours 20 minutes using // and %, not typed numbers.
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.
A ride needs riders to be at least 120 cm tall and at least 8 years old. Replace each ___ so the program prints True, then False.
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 the average of three test scores, Average: 80.0, but it prints the wrong number. Fix the expression.
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.
This program takes a number apart. Each row shows number and last each time either changes, once both exist.
number = 472 last = number % 10 number = number // 10 last = number % 10 number = number // 10
Sign 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: Use ** instead of multiplying side by itself.
The program multiplies side by itself to get a square and a cube. Rewrite both calculations with **. The output must stay the same.
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 year is a leap year if it divides by 4, except years that divide by 100, unless they also divide by 400. Store each year in year and print the year and a bool for 2024, 1900 and 2000, giving:
2024 True1900 False2000 True
Use one expression with %, and and or; do not type the answers.
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.