LearnFrenzy
Sign in Take a free test

Strings · Predict the Output · Question 10

Comparing strings Answer, explanation & discussion

  • Output
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 10 Back to Exercise

What is the output of the following Python program?

main.py
print("apple" < "Apple", "10" < "9", "abc" < "abd", "Zebra" < "apple", "ab" < "abc")
  • A False True True True True Correct
  • B True False True False True
  • C False False True True False
  • D False True False True True
Correct Answer: Option A

Comparison is character by character by code point: "a" (97) > "A" (65); "1" < "9", so "10" < "9"; a prefix is smaller than the longer string.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links