Hello, I just did the Python “Guido’s Lasagna” exercise. My code passed all the tests but there were a couple things flagged that I wanted to get some help with for the sake of refining my code. This is my code:
#TODO: define the ‘EXPECTED_BAKE_TIME’ constant.
import lasagna
lasagna.EXPECTED_BAKE_TIME = 40
#TODO: Remove ‘pass’ and complete the ‘bake_time_remaining()’ function below.
def bake_time_remaining(elapsed_bake_time):
“”"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`.
"""
return lasagna.EXPECTED_BAKE_TIME - elapsed_bake_time
#TODO: Define the ‘preparation_time_in_minutes()’ function below.
You might also consider using ‘PREPARATION_TIME’ here, if you have it defined.
def preparation_time_in_minutes(no_of_layers):
“”"
param no_of_layers: int - the number of layers of lasagna being added
return: int - the amount of time in minutes it will take for the extra layers
of lasagna to be added, assuming each additional layer takes 2 minutes to bake.
This function takes an integers representing the number of lasagna layers and
calculates the amount of time in minutes it will take to prepare the given
number of layers.
"""
return 2*no_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(no_of_layers, elapsed_bake_time):
“”"
param no_of_layers: int - the number of layers of lasagna being added
param elapsed_bake_time: int - baking time already elapsed
return: int - the amount of time spent baking so far
This function takes two integers representing the number of lasagna layers and
the time already spent baking and calculates the total elapsed minutes spent
cooking the lasagna.
"""
layers_prep_time = preparation_time_in_minutes(no_of_layers)
return layers_prep_time + elapsed_bake_time
And these were the errors I got:
Line 11 [W0511 fixme] : [“TODO: define the ‘EXPECTED_BAKE_TIME’ constant.”] was reported by Pylint.
There is an issue in the code that could lead to a bug or error in the program. While this error might not be severe, it could lead to more severe issues in the future. It is recommend the problem be addressed before proceeding further.
Line 15 [W0511 fixme ] : [“TODO: Remove ‘pass’ and complete the ‘bake_time_remaining()’ function below.”] was reported by Pylint.
Line 29 [W0511 fixme ] : [“TODO: Define the ‘preparation_time_in_minutes()’ function below.”] was reported by Pylint.
Line 12 [W0406 import-self ] : [“Module import itself”] was reported by Pylint.