Computer Science

The statement: bval = str1 > str2 shall return …………… as the output if two strings str1 and str2 contains "Delhi" and "New Delhi".

  1. True
  2. Delhi
  3. New Delhi
  4. False

Python Data Handling

1 Like

Answer

False

Reason — Python's lexicographical comparison compares strings character by character based on their ASCII values. In the case of "Delhi" and "New Delhi", the comparison stops at the first difference encountered, which is the comparison between 'D' and 'N'. Since 'N' has a greater ASCII value than 'D', the lexicographical comparison returns False.

Answered By

3 Likes


Related Questions