Lab, Lists, Tuples and Strings
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.
Given first = "Alan" and last = "Turing", print the initials A.T. and then the last name in reverse, gniruT.
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 ___ with a slice so the program prints the name without the extension, holiday, and the extension alone, jpg.
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 tries to change the first letter of a name in place and crashes. Fix it so it prints Mona, by building a new string.
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 ch and result each time either changes, once both exist. Strings are shown in quotes.
result = ""
for ch in "abc":
result = ch + resultSign 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 the slice [::-1] instead of a loop.
This program reverses a word with a loop. Rewrite it with a single slice and no loop. The output must stay tnemirepxe.
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.
For word = "Racecar", print four lines:
Length: 7Vowels: 3Middle: e (the character at index len(word) // 2)Palindrome: True (ignoring case, so compare lowercase copies)
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.