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.
Print a countdown from 3 to 1, one number per line, then print Liftoff!. Use a for loop with range().
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.
Replace each ___ so the program counts the letter s in mississippi and prints s: 4.
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 add the numbers 1 to 10 and print Sum: 55 once. It has two bugs: the range misses 10, and the total is reset and printed in the wrong places. Fix them.
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.
Read the program. Each row of the table is the moment i or total changes, starting once both exist. Fill in every value.
total = 0
for i in range(1, 4):
total = total + iSign 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 enumerate with start=1 instead of a counter you update yourself.
This loop keeps its own counter to number the tasks. Rewrite it with enumerate(..., start=1) and no manual counter. The output must not change.
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.
Print the 7 times table from 1 to 5, one line each, in the form 7 x 1 = 7. After the table, print Even results: 2, counting how many of the results are even.
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.