Lab, In Depth Projects
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.
Write shift_letter(ch, shift) that shifts a lowercase letter by shift places, wrapping round the alphabet, and returns any other character unchanged. Then print "hello, world" with every character shifted by 13, so the program prints uryyb, jbeyq.
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 ___ with the method that builds a translation table from two strings, so the program prints dwwdfn dw gdzq.
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.
Lowercase letters encrypt correctly, but the capitals come out as the wrong letters. Fix the function so the program prints:
Khoor, Zruog!
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 out each time one of them changes, once both exist.
shift = 3
out = ""
for ch in "xyz":
out = out + chr((ord(ch) - 97 + shift) % 26 + 97)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: decrypt must return encrypt(text, -shift), with no second shift formula.
decrypt repeats almost all of encrypt. Rewrite decrypt so it simply returns encrypt with the negative shift. 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.
Write crack(secret) that tries every shift from 0 to 25, decrypts secret with each, and returns (shift, text) for the decryption with the most words in COMMON. When several shifts tie, return the smallest one. The program should print:
(7, 'the cat is in the garden') (19, 'meet me at the station at noon') (0, 'it is a secret')
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.