Solution 1

burger = False

# Flip this burger using not
burger_flipped = not burger


number = 5

# Create an inequality checking if number is greater than 3, then invert the result (all on one line)!
result = not (number > 3)

Inverting Booleans

There are a lot of different ways of writing the same code to accomplish something.

To demonstrate this, let's take a look at booleans.

You can either check that something is False or, if you are sure that it is a boolean, you can check if it is not True. Same thing, right?

variable = False

# Two ways of doing the same thing
print(variable is False) # True
print(not variable) # True
# Note that the second way uses less code so it is preferred

# Inverting a boolean
true_variable = True
variable = not true_variable 
print(variable) # False

Use the not operator to check for the opposite of something in the following code!

Test Cases

test result - Run Test

def test_result():
    assert result is False

test burger - Run Test

def test_burger():
    assert burger_flipped is True
burger = False # Flip this burger using not burger_flipped = ? number = 5 # Create an inequality checking if number is greater than 3, then invert the result (all on one line)! result = ?