Example
Logical Operators and, or, not
Combining conditions with logical operators and, or and not.
Showing 1–10 of 171
Example
Combining conditions with logical operators and, or and not.
Example
Order of operations in Python. Parentheses, exponents, multiplication, division, addition.
Article Mini projects
Dive into the world of planetary orbits using Python's Turtle library. Discover how orbital eccentricity shapes cosmic paths, from Earth's near-circular orbit to a comet's elliptical journey. Code…
Challenge
A loop over range(1, 10) logs nine orbits of a ten-orbit flight. Predict the last line, find out where range() stops, fix it with ORBITS + 1, then list every third orbit with a range() step.
Challenge
…spacecraft into safe mode when the battery is under 20% or contact has been lost for over 10 minutes, using or, then name the rule that fired with boolean variables and an if/elif chain.
Challenge
Route an uploaded file to images, telemetry or rejected by its extension with an if/elif chain and endswith(), then cope with capitals, spaces and more extensions without changing the name that is…
Challenge
int() cuts the decimals off, round() rounds, and round(2.5) gives 2. Predict the difference, investigate Python's rounding rule, then round a fuel reading two ways.
Example
…can return complex data structures like dictionaries or lists.
Challenge
…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.
Challenge
…lower-case emails, then reject sign-ups with no name or a broken email and drop duplicates by email, saying why for each one.