BaşlayınÜcretsiz Başlayın

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.

Bu egzersiz

Introduction to Python for Developers

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

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

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# 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.')
Kodu Düzenle ve Çalıştır