The following code:
print(chr(ord('z') ‑ 2)) prints:
- a
- y
- z
- x
Explanation: The ord() function in Python returns the Unicode code of the given character. A lower-case z returns a 122. Then 2 is subtracted from 122, which results in 120. Finally, the 120 value is converted to its Unicode character x using the chr() function. So, x is printed in the console.
More Questions: Python Essentials 2 – Module 2 Test
Please login or Register to submit your answer