Question

A cookie recipe calls for the following ingredients: • 1.5 cups of sugar • 1 cup...

A cookie recipe calls for the following ingredients:
• 1.5 cups of sugar
• 1 cup of butter
• 2.75 cups of flour
The recipe produces 48 cookies with this amount of ingredients. Write a program
that asks the user how many cookies they want to make and then displays the number
of cups of each ingredient needed for the specified number of cookies in the following format:

You need 5 cups of sugar, 3 cups of butter, and 7 cups of flour.

SAMPLE RUN #2: python3 IngredientAdjuster.py

Interactive Session Standard Input Standard Error (empty) Standard Output Hide Invisibles

Highlight: NoneStandard Input OnlyPrompts OnlyStandard Output w/o PromptsFull Standard OutputAllShow Highlighted Only

Enter·number·of·cookies:48↵
You·need·1.5·cups·of·sugar,·1.0·cups·of·butter,·and·2.75·cups·of·flour.↵
1 0
Add a comment Improve this question Transcribed image text
Answer #1

Code -

#value for sugar required for 48 cookies
SUGAR_FOR_48_COOKIES = 1.5
#value for butter required for 48 cookies
BUTTER_FOR_48_COOKIES = 1
#value for flour required for 48 cookies
FLOUR_FOR_48_COOKIES = 2.75
#ask user how many cookies they want to make
num = int(input("How many cookies they want to make: "))
#calcular sugar amount for num amount of cookies
sugarAmount = (SUGAR_FOR_48_COOKIES / 48) * num
#calcular butter amount for num amount of cookies
butterAmount = (BUTTER_FOR_48_COOKIES / 48) * num
#calcular flour amount for num amount of cookies
flourAmount = (FLOUR_FOR_48_COOKIES / 48) * num
#print output
print("You need "+str(sugarAmount)+" cups of sugar, "+str(butterAmount)+" cups of butter, and "+str(flourAmount)+" cups of flour")

Output -

How many cookies they want to make: 48 You need 1.5 cups of sugar, 1.0 cups of butter, and 2.75 cups of flour ... Program fin

pls do give a like , thank you

Add a comment
Know the answer?
Add Answer to:
A cookie recipe calls for the following ingredients: • 1.5 cups of sugar • 1 cup...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Programming Challenges 145 6. Ingredient Adjuster A cookie recipe calls for the following ingredients: • 1.5...

    Programming Challenges 145 6. Ingredient Adjuster A cookie recipe calls for the following ingredients: • 1.5 cups of sugar • 1 cup of butter • 2.75 cups of flour The recipe produces 48 cookies with this amount of the ingredients. Write a program that asks the user how many cookies he or she wants to make, then displays the number of cups of each ingredient needed for the specified number of cookies. 7. Box Office A movie theater only keeps...

  • 3. Jim is making shortbread cookies. The recipe calls for 1 cup of butter, 'cup sugar,...

    3. Jim is making shortbread cookies. The recipe calls for 1 cup of butter, 'cup sugar, and 243 cups flour. Jim had already put in the 1 cup of butter and 24 cups flour, but then he accidentally added 1 cup of sugar to the mixture. Which of the following shows how much butter and flour he must now add to achieve the proportion? A) 1 cup of butter and 2 cups flour B) 1 cup of butter and 1...

  • A recipe that makes 18 cookie calls for 3/4 cup of sugar

    A recipe that makes 18 cookie calls for 3/4 cup of sugar. Howbmuch sugar is needes to make 24 cookies using this recipe?

  • 1) We have returned to our ingredients dictionary. We want to display the ingredients in alphabetical...

    1) We have returned to our ingredients dictionary. We want to display the ingredients in alphabetical order. Dictionaries cannot be sorted, so we need to use the items method to convert the dictionary into a list of tuples. Then we can sort that new list of tuples, then display the ingredients. Use items and list to convert ingredients into a list of tuples. Sort the new list, called ingred_list Write a for loop which goes through each tuple in ingred_list....

  • def main(): n = int(input('Enter number of cookies: ')) r = n / 48 sugar =...

    def main(): n = int(input('Enter number of cookies: ')) r = n / 48 sugar = r * 1.5 butter = r flour = r * 2.75 print('You need ' + str(sugar) + ' cups of sugar, ' + str(butter) + ' cups of butter, and ' + str(flour) + ' cups of flour for ' + str(n) + ' cookies.') main() Please explain what each function in this program does? Python

  • 15. The following recipe is for a spice cake Ingredients 3 % cups cake flour 3%...

    15. The following recipe is for a spice cake Ingredients 3 % cups cake flour 3% teaspoon double acting baking powder I teaspoon salt 2 teaspoons cinnamon 5 teaspoon cloves 2 teaspoons grated orange rind 2/3 cup vegetable oil 4 cup water ½ cup skimmed milk 4 egg whites 4 tsp cream of tartar 1 ½ cups sugar teaspoon allspice Procedure I. Grease two 9-inch square pans, and preheat oven to 375 2. Sift together into a mixing bowl the...

  • A recipe calls for 2 cups flour and 1 cup milk to make six servings. Ming...

    A recipe calls for 2 cups flour and 1 cup milk to make six servings. Ming has plenty of flour, but only 6 cups of milk. How many servings can he make? Ming can make servings with 6 cups of milk. (Simplify your answer. Type an integer, fraction, or mixed number.)

  • 1 tsps ml 1. Analysis of basic soda bread recipe 1 cup milk 2 cups flour...

    1 tsps ml 1. Analysis of basic soda bread recipe 1 cup milk 2 cups flour 1 tbsp white sugar 2 tbsp white vinegar 2 tsp baking soda ½ tsp salt How many moles of baking soda (sodium bicarbonate: NaHCO3 - MW 84; density 2.2) are there? a) b) Acetic acid makes up 5% of distilled white vinegar. How many moles of acetic acid (CH3COOH - MW 60; density- 1) are there? c) How many moles of CO2 will be...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT