Easy question from beginner `bout Boolean in Python

Why does Boolean define that “SEA” is < smaller than “sea”,could you explain please,yeah I am a dummie ,but still wanna know and move forward)Please:smile:

Hi @Marryrr and welcome to the community!

I don’t understand your question. If you write:


Both are going to return “false”, because both are “true”. I suggest you enter here to understand how does bool work.

1 Like

Ok ,thank you!Could I ask you one more beginner question ?%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%20(2)|690x388
How could I accomplish this code(on the picture) ,so both “We are fine” would be written and the code was stopped after the condition was accomplished?Now the output is only absent.

You have “6>10” in the second if, that is not logical (it is false) so it won’t print “We are fine”. You should change that.

So you mean that if program sees that the first condition is not right then it does not go to the next step,is it so?Could I interchange the places of the first statement and the second one?

1 Like

Try it and you will see :wink:

You can find the reason in §5.8 of the Python documentation:

The comparison uses lexicographical ordering: first the first two items are compared, and if they differ this determines the outcome of the comparison; if they are equal, the next two items are compared, and so on. … Lexicographical ordering for strings uses the Unicode code point number to order individual characters.

The Unicode codepoint of “S” is 83, and the codepoint of “s” is 115, therefore "s" > "S", therefore "sea" > "SEA".

1 Like

Wow!Thank you for nice explanation!Where could I find codepoints of other letters?Is it always so that big letters codepoint is smaller than the codepoint of its little equivalent?

In Python, you can use ord(char) to find the codepoint of character char. For example: ord('A') == 65.

For all Basic Latin characters (English alphabet a–z, with no accent marks), the lowercase version (such as ‘a’) is 32 codepoints above the uppercase version (such as ‘A’).

However, this isn’t true for all scripts, or even extended Latin alphabet characters. For example, the German character ‘ß’ was originally added to Unicode only in lowercase form. The uppercase version ‘ẞ’ was added much later, so its codepoint is much higher.

1 Like