- 2

What is the output of this code? print(“hey” < “hay”)

why

5th Oct 2022, 1:27 PM
garima
garima - avatar
3 Answers
+ 3
> What is the output? You can find it by running the code on sololearn playground. Have you tried it? > Why is this the output? Alphabetic ordering. 👉PLEASE TAG "python" NOT "#why"
5th Oct 2022, 1:32 PM
Lisa
Lisa - avatar
+ 2
It is comparing 2 strings lexiographycally.. Each of character of first string is compared with corresponding second string character. It returns False. "hey" is greater than "hay" since 'e' > 'a' is True. (compared by ascii values). 'e' < 'a' false so "hey" < "hay" False. hope it helps...... add relevant tags..
5th Oct 2022, 1:35 PM
Jayakrishna 🇼🇳
+ 2
print("a"<"b") #True print("z">"za") #False print("hello">="hello")#True
5th Oct 2022, 7:57 PM
NinjaGamer
NinjaGamer - avatar