0
Greater than / Smaller than Operators
Q1. Any one explains on this? ---------------- print ('a' > 'b') print ('Bob' > 'Dave') False False ----------------- Why is False here? Does it mean that 'Strings cannot be compared'? ------------------- ------------------- Q2. How to understand the concept 'Control Flow'?
6 odpowiedzi
+ 5
Coucou MO
ASCII value of a is less than b
ASCII value of B is less than D
Comparing ASCII value of first character
+ 4
Strings are compared lexiographically..
1) 'a' > 'b' false because 'a' ascii value is 97. For 'b' is 98
So 97>98 false.
and
'Bob' > 'Dave' false because
'B' > 'D' => 66 > 68 false.
When equal only then go on compare next character... And repeated until end.
'ab' > 'aa' returns true because 'a' and 'a' equal, and next 'b' > 'a' is true.
+ 3
Coucou MO
ASCII stands for American Standard Code for Information Interchange. Computers can only understand numbers, so an ASCII code is the numerical representation of a character such as 'a' or '@' or an action of some sort.
https://www.asciitable.com/
0
What does 'ASCII' mean? I am learning Python without any previous knowledge...
0
Thank you for all the answers below the post! Very helpful!