#Lasagna Problem : Python
3 messages · Page 1 of 1 (latest)
EXPECTED_BAKE_TIME = 0
PREPARATION_TIME = 0
MINUTES_PER_LAYER = 0
def bake_time_remaining(elapsed_bake_time : int):
"""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 EXPECTED_BAKE_TIME - elapsed_bake_time
def prepartion_time_in_minutes(PREPARATION_TIME, MINUTES_PER_LAYER):
PREPARATION_TIME * MINUTES_PER_LAYER
def elapsed_time_in_minutes():
pass
## 1. Define expected bake time in minutes
- You need to [name][naming] a [constant][constants], and [assign][assignment] it an [integer][numbers] value.
This constant should be the first thing after the docstring that is at the top of the file.
Remember to remove the #TODO comment after defining the constant.
## 2. Calculate remaining bake time in minutes
- You need to define a [function][defining functions] with a single parameter representing the time elapsed so far.
- Use the [mathematical operator for subtraction][numbers] to subtract values.
- This function should [return a value][return].
## 3. Calculate preparation time in minutes
- You need to define a [function][defining functions] with a single parameter representing the number of layers.
- Use the [mathematical operator for multiplication][numbers] to multiply values.
- You could define an extra _constant_ for the time in minutes per layer rather than using a "magic number" in your code.
- This function should [return a value][return].
## 4. Calculate total elapsed cooking time (prep + bake) in minutes
- You need to define a [function][defining functions] with two parameters.
- Remember: you can always _call_ a function you've defined previously.
- You can use the [mathematical operator for addition][python as a calculator] to sum values.
- This function should [return a value][return].