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.
Deze oefening maakt deel uit van de cursus
Introduction to Python for Developers
Oefeninstructies
- Store the number of garlic cloves (
3) as an integer variable calledgarlic_cloves. - Store the amount of olive oil in tablespoons (
2.5) as a float variable calledolive_oil_tbsp. - Increase the amount of olive oil by
1tablespoon and store it tonew_olive_oil_tbsp.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# 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)