True / false and simple comparisons
P40.text-and-numbers.03 · Audience: guest, language-pro, it-ml · Prerequisites: Text (strings)
Look at a word and decide, by eye: is it longer than five letters? That yes-or-no judgement is something you make constantly. This module shows how Python answers the same yes-or-no questions for you — one kind of comparison at a time.
ⓘ Concept: Comparing gives True or False
True or False. You get one by comparing with > and < (bigger / smaller): len(word) > 5 asks "is this word longer than five letters?" and hands back True or False.Why it matters — Every later automation — 'keep the long words', 'skip the empty lines' — rests on a yes-or-no test. Naming True and False now makes those choices readable later.
Ask the mentor about this module
Ask a question about this content. The mentor explains and grounds its answer in what you are studying; asking is recorded as a learning signal, not a grade.
🎓 Practice ladder
1 graded rung · ~4 minYour turn: judge two words — is one longer than five letters, is the other exactly three, and are both true at once? Write the comparisons you just stepped through, then press Run.
Explorer rung — is this word long?
Loading exercise…
Where next?
Later in Text & Numbers
Go up a level