Issue
When we execute the program print('a' > 'b') it gives us the answer False.
When we execute the program print('a' > 'A') it gives us the answer True.
Please help me with a detailed explanation.
Solution
when comparing characters using the < or > it converts it to an integer.
according to ASCII Table
Meaning:
- a is 97 decimal
- b is 98 decimal
- A is 65 decimal
- B is 66 decimal
therefor:
print('a' > 'b') is false because print(97 > 98)
and then:
print('a' > 'A') is true because print(97 > 65)
Answered By - Dean Van Greunen Answer Checked By - Marilyn (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.