The following code:
print(chr(ord('p') + 2))
- will print r
- will print s
- will print t
- will print q
Explanation: The chr() function returns the character that represents the specified Unicode, while the ord() function returns the Unicode code from a given character (in this case, ‘p’ → 112).
Because the ord() function returns 112, the chr() function takes 114 as its argument (112 + 2 → 114), and returns r, because the character represents the Unicode code 114.
More Questions: Python Essentials 2 (PE2) Course Final Test
Please login or Register to submit your answer