Check your understanding of the previous reading: converting between characters and their ASCII codes with chr and ord.
Convert all of the following numbers into their ASCII character code (as if you passed them into the chr function).
Do not include quotes.
48:
chr(48) is 0, the digit zero: the digits 0 to 9 have the codes 48 to 57.
40:
chr(40) is (, the left parenthesis.
74:
chr(74) is J, uppercase J: the uppercase letters have the codes 65 (A) to 90 (Z); lowercase j is 106.
109:
chr(109) is m, lowercase m: the lowercase letters have the codes 97 (a) to 122 (z); uppercase M is 77.
126:
chr(126) is ~, the tilde, the last printable character.
The ord function consumes a string, and the chr function returns a string. In both functions, this string is the same length. How many characters are in the string?
ord needs a string of exactly one character (ord("FF") raises a TypeError), and chr returns one character, so the string has 1 character.
Convert all of the following ASCII character codes into their integer representation (as if you passed them into the ord function).
!:
ord("!") is 33, the exclamation mark.
.:
ord(".") is 46, the period.
9:
ord("9") is 57, the digit 9: the digits 0 to 9 have the codes 48 to 57.
H:
ord("H") is 72, uppercase H: the uppercase letters have the codes 65 (A) to 90 (Z).
z:
ord("z") is 122, lowercase z, the last lowercase letter (a is 97).