True / false and simple comparisons
P40.text-and-numbers.03 · Audience: Guest, Language professional, IT/ML learner · Prerequisites: Text (strings)
Where next?
Later in Text & Numbers
Go up a level
P40.text-and-numbers.03 · Audience: Guest, Language professional, IT/ML learner · Prerequisites: Text (strings)
Later in Text & Numbers
Go up a level
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.
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 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.
Off by default. The mentor always gets your file; this only decides whether your own copy stays here. Copies live in this browser only - they do not follow you to another device, and clearing site data removes them.
Your 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.
Loading exercise…
Loading your notes...