PCAP-31-03 practice question 10 of 25
Which of the equations are True? (Select two answers)
Full set: 147 questionsFor a one-character string x, ord(x) gives its Unicode code point (int); applying chr to that code returns the original character, so chr(ord(x)) == x is True. Conversely, if x is an int code point, chr(x) yields the character and ord on that character restores the original int, making ord(chr(x)) == x True.
B. ord()’s argument must be str of length 1; passing int from first ord raises TypeError.
C. chr() needs int; inner chr returns str, so outer chr raises TypeError.
1. Python 3.11 Library Reference, “Built-in Functions”, §ord, §chr,
https://docs.python.org/3/library/functions.html#ord
2. University of Michigan PY4E, “Unicode in Python”, Week 6 notes, explanatory example.
Keep practicing
Take the free PCAP-31-03 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other PCAP-31-03 practice questions
- Question 3How many elements will the list2 list contain after execution of the following snippet? l…
- Question 6Select the valid fun () invocations: (select two answers) def fun (a, b=0): return a*b
- Question 7Is it possible to safely check if a class object has a certain attribute0
- Question 13Which of the following lambda function definitions are correct? (Select two answers)
- Question 15Which of the following invocations are valid? (Select two answers)
- Question 16Which of the following words can be used as a variable name? (Select two valid names)
