Which of the following Python type-conversion functions converts a character…
2024
Which of the following Python type-conversion functions converts a character into its integer Unicode code point?
Answer: D. ord() — ConceptPython’s built-in conversion functions accept particular input types and produce particular representations. ord(s) maps a one-character Unicode string…
- A.
tuple()
- B.
dict()
- C.
set()
- D.
ord()
Attempted by 380 students.
Show answer & explanation
Correct answer: D
Concept
Python’s built-in conversion functions accept particular input types and produce particular representations.
ord(s) maps a one-character Unicode string to its integer code point, while chr(n) performs the reverse mapping.
Application
The stem asks for a mapping from one character to an integer code point.
Apply the character-to-code-point function:
ord('A')returns65.Therefore the function required by the stem is
ord().
Contrast
tuple()constructs a tuple from an iterable.dict()constructs a dictionary from mappings, key–value pairs, or keyword arguments.set()constructs a set of unique elements from an iterable.
Cross-check
Reverse the example: chr(65) returns 'A', confirming the code-point mapping.
Result
The required function is ord().