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 | |
|---|---|---|
| 1ord("A") | Achr(2 + ord("A")) | |
| 2chr(66) | Bord("D") - ord("A") | |
| 3Convert a letter into a position from 0 to 25 by taking away the code of "A" | Cord() needs a character such as "A", not a number. To turn 65 into a letter, use chr(65). | |
| 4Turn a position from 0 to 25 back into an uppercase letter by adding the code of "A" and using chr() | Dchr() needs a number code such as 65, not a letter. To get the code of "A", use ord("A"). | |
| 5ord(65) | EReturns the character for the number code 66, which is "B" | |
| 6chr("A") | FReturns the number code of the character A, which is 65 |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
ord() and chr() — ord("A") returns the number code of a character (65). chr(65) turns a number code back into its character ("A"). Ciphers use them to change letters to numbers and back.print(ord("A"))print(chr(65))pos = ord("D") - 65
print(pos)letter = "C"
num = ord(letter) - 65
print(num)print(chr(ord("A") + 1))