Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

You must login to ask a question.

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Quizzma Latest Articles

3.5.9 Recipe CodeHS Answers

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 Team

Quizzma Team

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.

Related Posts

Leave a comment