Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1ch.isalpha() | AReturns True if the letter ch is a capital letter, so the loop knows whether to shift from 'A' or from 'a' | |
| 2ch.isupper() | Belse: result += ch | |
| 3Only shift a character if it is a letter, so spaces and punctuation stay unchanged | Cif ch.isalpha(): | |
| 4Leave a character unchanged when it is not a letter by adding it to the result as it is | Disalpha() is a string method, so it is written after the character with a dot. It must be ch.isalpha(). | |
| 5if ch.isalpha: | EThe brackets are missing, so Python checks the method itself and not its result. It must be ch.isalpha(). | |
| 6if isalpha(ch): | FReturns True if the character ch is a letter, and False for spaces, digits and punctuation |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
ch.isalpha() — Returns True if the character ch is a letter, so a Caesar loop can shift letters and leave spaces and punctuation unchanged. ch.isupper() checks for capitals.for ch in message:
if ch.isalpha():
result += chfor ch in message:
if ch.isalpha():
shift = 3ch = 'q'
print(ch.isupper())
# prints Falseif not ch.isalpha():
result += ch
continuebase = 65 if ch.isupper() else 97