Get startedGet started for free

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.

This exercise is part of the course

Introduction to Python for Developers

View Course

Exercise instructions

  • 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.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# 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.')
Edit and Run Code