Arithmetic Operators: Exercises


2. The or Operator. In Python, the or operator is used to combine two conditions. It returns True if at least one of the conditions is True, and False otherwise.

For example, the expression (x > 5) or (y < 10) evaluates to True if either x is greater than 5 or y is less than 10 (or both).


# Define two boolean values condition1 = True condition2 = False # Use the 'or' operator to combine conditions result = condition1 ___ condition2 # Print the result print(result) # Define two boolean values condition1 = True condition2 = False # Use the 'or' operator to combine conditions result = condition1 or condition2 # Print the result print(result) test_object("condition1") test_object("condition2") test_object("result") success_msg("Correct!")
Remember that the 'or' operator returns 'True' if at least one of the conditions is 'True'.

Previous Exercise Next Exercise