Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2.12 Ch 2 Program: Cooking measurement converter (Python 3) (1) Prompt the user

ID: 3742020 • Letter: 2

Question

2.12 Ch 2 Program: Cooking measurement converter (Python 3)

(1) Prompt the user for the number of cups of lemon juice, water, and sugar needed to make lemonade. Prompt the user to specify the number of servings the recipe yields. Output the ingredients and serving size. (Submit for 2 points).

Note: This zyLab outputs a newline after each user-input prompt. For convenience in the examples below, the user's input value is shown on the next line, but such values don't actually appear as output when the program runs.

(2) Prompt the user to specify the desired number of servings. Adjust the amounts of each ingredient accordingly, and then output the ingredients and serving size. (Submit for 4 points, so 6 points total).

(3) Convert the ingredient measurements from (2) to gallons. Output the ingredients and serving size. Note: There are 16 cups in a gallon. (Submit for 2 points, so 8 points total).

Explanation / Answer

# 1 lemon = float(input('Enter amount of lemon juice (in cups): ')) water = float(input('Enter amount of water (in cups): ')) nectar = float(input('Enter amount of agave nectar (in cups): ')) servings = float(input('How many servings does this make? ')) print() print('Lemonade ingredients - yields ' + str(servings) + ' servings') print(str(lemon) + ' cup(s) lemon juice') print(str(water) + ' cup(s) water') print(str(nectar) + ' cup(s) agave nectar') # 2 required_servings = float(input('How many servings would you like to make? ')) print() print('Lemonade ingredients - yields ' + str(required_servings) + ' servings') print(str(lemon*required_servings/servings) + ' cup(s) lemon juice') print(str(water*required_servings/servings) + ' cup(s) water') print(str(nectar*required_servings/servings) + ' cup(s) agave nectar') # 3 print('Lemonade ingredients - yields ' + str(required_servings) + ' servings') print(str(lemon*required_servings/servings/8) + ' gallon(s) lemon juice') print(str(water*required_servings/servings/8) + ' gallon(s) water') print(str(nectar*required_servings/servings/8) + ' gallon(s) agave nectar')