Do Letters and Special Characters Have Numerical Values Assigned to Them by Default?
I noticed while playing with the code for the "Try It Yourself" before the 4th question that "a" is less than "b" and "b" is less than "c", so it would follow that this continues through the rest of the alphabet. I then tried it with upper case letters and noticed that not only do they retain the same pattern, i.e. "A" is less than "B" and so on, but also that upper case letters are less than lower case letters, i.e. "A" is less than "a". The trend seems to continue with special characters as well. My question then is this: Are letters in Python assigned a numerical value by default? Are special characters also assigned numerical values? It seems a reasonable assumption that perhaps "a"-"z" = 1-26 and "A"-"Z" = 27-52 respectively, and that special characters would begin at 53. Or rather than numerical values were they simply given a hierarchy, so to speak, where one character is greater than another in the same way that a king is greater than an earl or a president is greater than a governor? What is the story here, and will this knowledge be relevant for coding later on or is it just an interesting quirk of Python? Edit: I've saved the code that I was playing with and made it public if anyone wants to take a look or play with it themselves.