3.5.9 Recipe CodeHS Answers

We thoroughly check each answer to a question to provide you with the most correct answers. Found a mistake? Tell us about it through the REPORT button at the bottom of the page. Ctrl+F (Cmd+F) will help you a lot when searching through such a large set of questions.

The most common answer for the 3.5.9 Recipe CodeHS is:

“””
This program asks the user for three ingredients,
three amounts, and a number of servings, and
determines how much of each ingredient is needed
to serve the specified number of servings.
“””
Write program here…
ia = str(input(“Enter ingredient 1: “))
ib = float(input(“Ounces of “+ str(ia)))
ja = str(input(“Enter ingredient 2: “))
jb = float(input(“Ounces of “+ str(ia)))
ka = str(input(“Enter ingredient 3: “))
kb = float(input(“Ounces of “+str(ia)))
numserv = int(input(“Number of servings: “))
print(“Total ounces of ” + ia + “: ” + str((ibnumserv))) print(“Total ounces of ” + ja + “: ” + str((jbnumserv)))
print(“Total ounces of ” + ka + “: ” + str((kb*numserv)))

This code calculates the total amount of each ingredient needed based on the number of servings. However, there are a few issues and improvements that can be made to the code:

  1. A typo in this input prompts for the amounts of ingredients 2 and 3. They incorrectly reference ia instead of ja and ka respectively.
  2. The formula for calculating the total amount of each ingredient is not properly enclosed in parentheses.
  3. For better readability, it’s good practice to use spaces around operators.

Here is the corrected version of this program:

# Ask user for ingredients and their amounts
ia = input("Enter ingredient 1: ")
ib = float(input("Ounces of " + ia + ": "))
ja = input("Enter ingredient 2: ")
jb = float(input("Ounces of " + ja + ": "))
ka = input("Enter ingredient 3: ")
kb = float(input("Ounces of " + ka + ": "))

# Ask for the number of servings
num_serv = int(input("Number of servings: "))

# Calculate and print the total amount of each ingredient needed
print("Total ounces of " + ia + ": " + str(ib * num_serv))
print("Total ounces of " + ja + ": " + str(jb * num_serv))
print("Total ounces of " + ka + ": " + str(kb * num_serv))

This program will now correctly ask for three ingredients, their amounts in ounces, and the number of servings. It then calculates and displays the total amount of each ingredient needed to serve the specified number of servings.

Was this helpful?

quizzma
Quizzma Team
+ posts

The Quizzma Team is a collective of experienced educators, subject matter experts, and content developers dedicated to providing accurate and high-quality educational resources. With a diverse range of expertise across various subjects, the team collaboratively reviews, creates, and publishes content to aid in learning and self-assessment.
Each piece of content undergoes a rigorous review process to ensure accuracy, relevance, and clarity. The Quizzma Team is committed to fostering a conducive learning environment for individuals and continually strives to provide reliable and valuable educational resources on a wide array of topics. Through collaborative effort and a shared passion for education, the Quizzma Team aims to contribute positively to the broader learning community.




Leave a Comment

Your email address will not be published. Required fields are marked *