Lesson 10 of 34

and, or, not: Combining Conditions

8 min 25 XP

and: True only if both sides are True. or: True if at least one side is True. not: flips True to False and False to True.

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

A real example: to be eligible for a job, you need a degree and at least 60% marks.

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

Python has a shortcut to check a range: 18 <= age <= 60

Challenge

+25 XP

Read a year with input(). Print Yes if it is a leap year, otherwise No. Rule: divisible by 4 but not by 100, or divisible by 400.

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.