Goodnight guys, having trouble with my code. I’m following all the instructions but I’m not sure if I’m going about task 3 and 4 the right way.
"""Functions used in preparing Guido's gorgeous lasagna.
Learn about Guido, the creator of the Python language:
https://en.wikipedia.org/wiki/Guido_van_Rossum
This is a module docstring, used to describe the functionality
of a module and its functions and/or classes.
"""
#TODO: define the 'EXPECTED_BAKE_TIME' constant.
EXPECTED_BAKE_TIME = 40
#TODO: Remove 'pass' and complete the 'bake_time_remaining()' function below.
def bake_time_remaining():
"""Calculate the bake time remaining.
:param elapsed_bake_time: int - baking time already elapsed.
:return: int - remaining bake time (in minutes) derived from 'EXPECTED_BAKE_TIME'.
Function that takes the actual minutes the lasagna has been in the oven as
an argument and returns how many minutes the lasagna still needs to bake
based on the `EXPECTED_BAKE_TIME`.
"""
remaining_bake_time = EXPECTED_BAKE_TIME - elapsed_bake_time
return remaining_bake_time
bake_time_remaining (10)
#TODO: Define the 'preparation_time_in_minutes()' function below.
# You might also consider using 'PREPARATION_TIME' here, if you have it defined.
PREPARATION_TIME = preparation_time_in_minutes(number_of_layers)
def preparation_time_in_minutes(number_of_layers):
#TODO: define the 'elapsed_time_in_minutes()' function below.
# Remember to add a docstring (you can copy and then alter the one from bake_time_remaining.)
def elapsed_time_in_minutes(number_of_layers, elapsed_bake_time):
return number_of_layers + elapsed_bake_time
hello @ArtistYay, it is not necessary to call the function bake_time_remaining with a value. You can delete this line. If you are satisfied with the respective task, simply run the test. If everything is correct, this task will turn green, and you can move on to the next task. I hope I was able to help you.
You should run the tests and look at the output. If there is a problem with your code, the tests will show you details. If you’re unsure what the test output means, you can copy paste it here (no screenshots please!)
I forgot to give an update. I passed the run with this script:
#TODO: define the 'EXPECTED_BAKE_TIME' constant.
EXPECTED_BAKE_TIME = 40
""" AKA assign a static variable, which is 40 based on task 1."""
#TODO: Remove 'pass' and complete the 'bake_time_remaining()' function below.
def bake_time_remaining(elapsed_bake_time):
""" defines a function that assigns a variable which subtracts elapsed_bake_time with EXPECTED_BAKE_TIME. The function is then called by putting 10 in the placeholder of elasped_bake_time."""
remaining_bake_time = EXPECTED_BAKE_TIME - elapsed_bake_time
return remaining_bake_time
bake_time_remaining (10)
#TODO: Define the 'preparation_time_in_minutes()' function below.
# You might also consider using 'PREPARATION_TIME' here, if you have it defined.
PREPARATION_TIME = 2
def preparation_time_in_minutes(number_of_layers):
""" The same goes for this function but instead of calling the function, the computer runs its own numbers. """
return PREPARATION_TIME * number_of_layers
#TODO: define the 'elapsed_time_in_minutes()' function below.
# Remember to add a docstring (you can copy and then alter the one from bake_time_remaining.)
def elapsed_time_in_minutes(number_of_layers, elapsed_bake_time):
""" Function returns prep time in minutes based on how many layers are in the lasagna and adds it with the time that past. """
return preparation_time_in_minutes(number_of_layers) + elapsed_bake_time