Aan de slagGa gratis aan de slag

Checking equality

Before scaling the recipe, you need to check if you have the exact amount of basil required. You'll use an equality check with an if/else statement to determine whether you have exactly the right amount or need to adjust your shopping list.

The integer variables basil_grams and required_basil have been preloaded for you.

Deze oefening maakt deel uit van de cursus

Introduction to Python for Developers

Cursus bekijken

Oefeninstructies

  • Use an equality check to compare basil_grams with required_basil in the if statement condition.
  • Else, print a message when you don't have the exact amount needed.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Check if you have exactly the right amount of basil
if basil_grams ____ required_basil:
    print('Perfect! You have exactly the right amount of basil.')
____:
    print('You need to adjust your basil quantity.')
Code bewerken en uitvoeren