Arithmetic Operators: Exercises


3. The not Operator. In Python, the not operator is used to negate a condition. It returns True if the condition is False, and False if the condition is True.

For example, the expression not (x > 5) evaluates to True if x is not greater than 5.

In the exercise below, set condition = True and then use the note operator to negate it.


# Define a boolean value condition = ___ # Use the 'not' operator to negate the condition result = ___ condition # Print the result print(result) # Define a boolean value condition = True # Use the 'not' operator to negate the condition result = not condition # Print the result print(result) test_object("condition") test_object("result") success_msg("Correct!")
Remember that the 'not' operator negates a condition, changing 'True' to 'False' and 'False' to 'True'.

Previous Exercise Next Exercise