So your program will start by assigning the number of guests to a variable (with name) n. Then, it will calculate the quantities (in grams or units) of each ingredient that it will store in three other variables: eggs, chocolate and sugar_vanilla.
Each of these quantities will be, as in the previous activity, truncated to the nearest unit.
This is my program :
def nombre(people):
e = int(egg)
egg=(3/4people)
c = int(chocolate)
chocolate=(100/4people)
s = int(sugar)
sugar=(1/4*people)
return str(e) + " egg " + str(c) + " gramme " + str(s) + " gramme "
print(nombre(7))
But I have an error :
Traceback (most recent call last):
File “”, line 1, in
File “”, line 2, in nombre
UnboundLocalError: local variable ‘egg’ referenced before assignment
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 6, in nombre
TypeError: unsupported operand type(s) for *: 'float' and 'function'
Store your program to a file. Let’s say food_storage.py
Execute the program from a terminal by giving the file name as a parameter to the Python interpreter: python3 food_storage.py
Depending on your platform and the way Python was installed the command could be: python3, python or py. This way of running the program will give a better traceback.
Show both the current program and the session in the terminal - including the start of the program and the complete traceback.