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…

  1. A.

    tuple()

  2. B.

    dict()

  3. C.

    set()

  4. 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

  1. The stem asks for a mapping from one character to an integer code point.

  2. Apply the character-to-code-point function: ord('A') returns 65.

  3. 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().

Explore the full course: Rssb Senior Computer Instructor

Loading lesson…