Which built-in Python function returns the character with the highest Unicode…

2024

Which built-in Python function returns the character with the highest Unicode code point in a non-empty string?

Answer: C. max()ConceptA Python string is an iterable sequence of Unicode characters. Character ordering is based on Unicode code points, and max(iterable) returns the…

  1. A.

    len()

  2. B.

    hvalue()

  3. C.

    max()

  4. D.

    long()

Attempted by 344 students.

Show answer & explanation

Correct answer: C

Concept

A Python string is an iterable sequence of Unicode characters. Character ordering is based on Unicode code points, and max(iterable) returns the greatest item under that ordering.

Therefore, for a non-empty string, applying max() compares its characters and returns the one with the highest code point.

Application

Consider 'Az': ord('A') is 65, while ord('z') is 122. Hence max('Az') returns 'z'. The same rule applies to the string in the question.

Contrast

  • len() returns the number of characters, not a character.

  • hvalue() is not a predefined Python built-in function.

  • long() is not a Python 3 built-in function; in Python 2 it referred to integer conversion rather than selecting a character.

Result

max() is the offered function that returns the character with the highest Unicode code point.

Explore the full course: Rssb Basic Computer Instructor

Loading lesson…