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.
This exercise is part of the course
Introduction to Python for Developers
Exercise instructions
- 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.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# 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)