+ 1

Boolean logic ? Explain ?

cat_1 = "CatF" cat_2 = "CatD" bool = cat_1 > cat_2 if bool==True: print("fatcat") else: print("deadcat")

2nd Nov 2020, 12:45 PM
Manish Kumar
4 Antworten
+ 1
Strings are checked lexicographically so 8n cat_1>cat_2, "CatF" >"CatD" upto " Cat" is but 'F' >'D' is true I.e Ascii of 'F' > Ascii 9f 'D' so it returns true finally....
2nd Nov 2020, 12:56 PM
Jayakrishna 🇮🇳
0
Jayakrishna🇮🇳 thank you ; ) I didn't know about that
2nd Nov 2020, 1:02 PM
Manish Kumar
0
Manish Kumar you're welcome. Just know about 'lexicographically sorting'.. You can find it clearly...
2nd Nov 2020, 1:04 PM
Jayakrishna 🇮🇳
0
It compares unicode numbers of the letters with same index
2nd Nov 2020, 10:17 PM
JFMINEBOY João Felipe
JFMINEBOY João Felipe - avatar