MulaiMulai sekarang secara gratis

Working with number variables

You're building a recipe scaler to adjust ingredient quantities for different party sizes. Your base recipe for pasta sauce serves 4 people and requires certain amounts of ingredients. Some ingredients come in whole units, while others need decimal measurements. You need to store these quantities using the appropriate data types so your recipe scaler can perform calculations accurately later.

Latihan ini adalah bagian dari kursus

Introduction to Python for Developers

Lihat Kursus

Petunjuk latihan

  • Store the number of garlic cloves (3) as an integer variable called garlic_cloves.
  • Store the amount of olive oil in tablespoons (2.5) as a float variable called olive_oil_tbsp.
  • Increase the amount of olive oil by 1 tablespoon and store it to new_olive_oil_tbsp.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Store the number of garlic cloves as an integer
garlic_cloves = ____

# Store the olive oil amount as a float
olive_oil_tbsp = ____
print(olive_oil_tbsp)

# Increase the olive oil amount
new_olive_oil_tbsp = 2.5 ____

print(garlic_cloves)
print(new_olive_oil_tbsp)
Edit dan Jalankan Kode