Question: PYTHON PROGRAMMING c) Create a function called cups_to_grams that converts cups of baking ingredients to grams. The function will take two arguments: the number of

PYTHON PROGRAMMINGPYTHON PROGRAMMING c) Create a function called cups_to_grams that converts cups of

c) Create a function called cups_to_grams that converts cups of baking ingredients to grams. The function will take two arguments: the number of cups (cups ) and a string that describes the type of ingredient (ingredient_type ). The function should convert cups to grams according to the following rules: This table represents the quantity in grams corresponding to one cup of each ingredient. str grams 'butter 226 'cream 240 'flour 125 'yeast' 149 If the ingredient_type is none of these options, the function should return -1 (negative one) to indicate that this ingredient type is not supported by our function. Examples of some tests you can run: cups_to_grams (1, 'butter') should return 226. cups_to_grams (0, 'cream') should return O. cups_to_grams (4, 'flour') should return 500. cups_to_grams ( 30, 'sugar') should return -1. You do not need to consider the cases where cups is a negative number. We are providing you with the docstrings as an aid; you should write the body of the function. n[ ]: def cups_to_grams (cups, ingredient_type): "Converts cups of baking ingredients to grams according to https://www.weekendbakery.com/cooking-conversions/ Arguments: cups : float, amount of cups of ingredient to convert flour_type: string, type of ingredient - Acceptable strings "butter", "cream", "flour", "yeast", otherwise it returns -1. Returns: gr : float, amount of grams, if the ingredient type is none of the above, it will return -1 # YOUR CODE HERE raise NotImplementedError()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!