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

Does anyone know how to code this using Python? The recipe needs to be input int

ID: 3591581 • Letter: D

Question

Does anyone know how to code this using Python? The recipe needs to be input into the program, not when you run it! Apparently that's the key part of this assignment. Please help if you can!

This is an exercise in coding with some repetition, with some output formatting and if-statements thrown in. Problem Description Many recipes tend to be rather small, producing the fewest number of servings that are really possible with the included ingredients. Sometimes one will want to be able to scale those recipes upwards for serving larger groups. This program's task is to determine how much of each ingredient in a recipe will be required for a target party size. The first inputs to the program will be the recipe itself. Here is an example recipe that comes from the story "Chitty Chitty Bang Bang" written by lan Fleming, who is much better known for introducing the world to James Bond: This is a recipe scaler for serving large crowds! Enter one ingredient per line, with a numeric value first Indicate the end of input with an empty line 4 tbsp cocoa 1/4 pound butter 2 tsp corn syrup 1 can evaporated milk 1 tsp water Here is the recipe that has been reconded 4 tbsp COcoa 1/4 pound butter 2 tsp 1 can 1 tsp corn syrup evaporated milk Water How many does this recipe serve? 16 How many people must be served? 25 Multiplying the recipe by 2 8 tbsp cocoa 2/4 pound butter 4 tsp corn syrup evaporated ilk Water 2 tsp Serves 32

Explanation / Answer

print("This is a receipe scaler for serving large crowds ")
print("Enter one ingrediant per line, with a numeric value first")
print("Indicate the end of the input by enpty line")

inp = input()
list = []
list.append(inp)
while len(inp) > 0 :
      inp = input()
      list.append(inp)

print("Here is the receipe recorder")
for i in range(len(list)-1):
   
    quant,unit,item = list[i].split(' ', 2)
    print("".join(quant.ljust(8)), end = '')
    print("".join(unit.ljust(8)), end = '')
    print("".join(item.ljust(15)))
    print()

n = int(input("How many does this receipe serve :"))
m = int(input("How many peple must be served :"))

count = 1
while n < m:
      count = count + 1
      n = 2*n
if count > 1:
   print("Multiplying the receipe by ", count)
   for i in range(len(list)-1):
   
    quant,unit,item = list[i].split(' ', 2)
    num,sl,deno = quant.partition('/')
    n1 = int(num) * count
    num = count * num
    if sl != "":
      str = str(n1) + "/" + str(deno)
    else:
      str = str(n1)
   
    print("".join(str.ljust(8)), end = '')
    print("".join(unit.ljust(8)), end = '')
    print("".join(item.ljust(15)))
    print()
  
   

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote