and — Easy Examples
Logical AND operator; returns True if both operands are true
Logical AND
Combining conditions that must all be true.
python
x = 10 if x > 0 and x < 100: print(f"{x} is between 0 and 100") name = "Alice" age = 25 if name and age >= 18: print(f"{name} is an adult") # Multiple conditions score = 85 attendance = 90 if score >= 70 and attendance >= 80 and score + attendance > 150: print("Passed the course")
Expected Output
10 is between 0 and 100 Alice is an adult Passed the course
'and' returns True only if both sides are True. It is used to combine multiple conditions that must all hold.
Want to try these examples interactively?
Open Easy Playground