Glossary · Phase 0 · Tools
Short-circuit evaluation
and and or stopping as soon as they know the answer, so the right-hand side may never run.
Try it now
Watch which lines the highlight visits. The first condition is False, so Python moves to the elif. That one is True, so it runs and the else is skipped entirely. Try it again in your head with ctr = 0.01.
Learn it properly
Decisions with if/else · Compare values and choose what happens next. About 40 minutes.
Other terms from the same lesson
- boolean: A value that is either True or False.
- falsy: A value that counts as false in an if: 0, 0.0, "", empty collections and None.
- truthy: A value that counts as true in an if: anything except zero, empty collections, empty strings and None.
Never trained an AI?
Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account.