Challenge
Assignment in a condition
An oxygen check uses = instead of == and has a line that isn't indented, so Python refuses to run it. Predict what happens, fix both errors one after the other, then write an if/else check yourself.
Showing 1–10 of 18
Challenge
An oxygen check uses = instead of == and has a line that isn't indented, so Python refuses to run it. Predict what happens, fix both errors one after the other, then write an if/else check yourself.
Example
While loop executes as long as condition is true. Controlling iteration with condition.
Example
Conditional if statement allows executing code only when condition is met.
Challenge
…check reports WARN for a reading of 63 because its elif conditions are in the wrong order, so CRITICAL can never run. Predict it, find the dead branch, fix the order, then write a four-level chain.
Example
Return can be used to exit function early when a condition is met.
Example
The else block executes when if condition is not met. Two possible paths.
Challenge
…a docking check built from three nested ifs into one condition joined with and, keeping the output exactly the same, then rewrite it as a flat if/elif chain that reports the first check that failed.
Quiz
…beginner quiz on Python if, elif and else: 15 questions on conditions, comparison and logical operators and indentation, with instant answers.
Challenge
…GO. With today's reports: Launch: GO Join the three conditions with and . lightning is True or False, so not lightning means "no lightning". "Under 30" means 30 itself is too much. Why it's on hold…
Example
Multiple conditions with elif. Checking several possibilities in sequence.