Python Strings · Question 19 · Hard
Three pairs of strings are compared with the less-than operator. What is the output?
print("apple" < "Apple", "10" < "9", "abc" < "abd")
- True False True
- False False True
- False True True
- True True True
Answer and explanation
Answer: C. False True True
Explanation: Strings are compared character by character using character codes. Capital letters come before small letters, so "apple" < "Apple" is False. "10" < "9" is True because '1' comes before '9', and "abc" < "abd" is True because 'c' comes before 'd'.
Previous: strip() is given a string of characters as its argument. What does this print? · Next: Two step slices of a word are joined, the second one reversed. What does this…
Practise python strings
Try a fresh set of python strings questions with an explanation after every answer, free and without signing up: Python Strings practice. Or sit a full placement mock test.
More python strings questions
- A slice with negative start and negative step is taken from a string. What is…
- split() and rsplit() are each limited to one split. What does this print?
- strip() is given a string of characters as its argument. What does this print?
- Two step slices of a word are joined, the second one reversed. What does this…
More python practice
Lists & Tuples · Dictionaries & Sets · Conditions & Loops · Functions & Scope · Comprehensions & Generators · Classes & Objects · Exceptions & Files · Built-ins & Standard Library
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge