From c1176864c52378d3b64310f8670f6553fece69a8 Mon Sep 17 00:00:00 2001 From: Mina-Ebraheem <64787775+mina123-daniel@users.noreply.github.com> Date: Fri, 28 Aug 2026 11:37:34 +0200 Subject: [PATCH] Implement baking and preparation time functions Define constants for expected bake time and preparation time. Implement functions to calculate bake time remaining, preparation time, and elapsed time in minutes. --- .../guidos-gorgeous-lasagna/lasagna.py | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/exercises/concept/guidos-gorgeous-lasagna/lasagna.py b/exercises/concept/guidos-gorgeous-lasagna/lasagna.py index bdf8ca9b77..88459598da 100644 --- a/exercises/concept/guidos-gorgeous-lasagna/lasagna.py +++ b/exercises/concept/guidos-gorgeous-lasagna/lasagna.py @@ -9,10 +9,11 @@ #TODO (student): define your EXPECTED_BAKE_TIME (required) and PREPARATION_TIME (optional) constants below. - +EXPECTED_BAKE_TIME = 60 +PREPARATION_TIME = 2 #TODO (student): Remove 'pass' and complete the 'bake_time_remaining()' function below. -def bake_time_remaining(): +def bake_time_remaining(elapsed_bake_time): """Calculate the bake time remaining. Parameters: @@ -25,19 +26,43 @@ def bake_time_remaining(): an argument and returns how many minutes the lasagna still needs to bake based on the `EXPECTED_BAKE_TIME`. """ - - pass + return (EXPECTED_BAKE_TIME - elapsed_bake_time) #TODO (student): Define the 'preparation_time_in_minutes()' function below. # To avoid the use of magic numbers (see: https://en.wikipedia.org/wiki/Magic_number_(programming)), you should define a PREPARATION_TIME constant. # You can do that on the line below the 'EXPECTED_BAKE_TIME' constant. # This will make it easier to do calculations, and make changes to your code. +def preparation_time_in_minutes(number_of_layers): + """Calculate the preparation time in minutes. + + Parameters: + number_of_layers (int): The number of layers. + Returns: + int: the total minutes needs to prepare the lasagna . + Function that takes the number of the layers to make lasagna, and + return the total minutes to make it`. + """ + return number_of_layers * PREPARATION_TIME #TODO (student): define the 'elapsed_time_in_minutes()' function below. +def elapsed_time_in_minutes(number_of_layers, elapsed_bake_time): + """Calculate the elapsed_time_in_minutes. + Parameters: + number_of_layers (the number of layers added to the lasagna) + elapsed_bake_time (the number of minutes the lasagna has spent baking in the oven already). + + Returns: + int: the total minutes you have been in the kitchen cooking . + + Function should return the total minutes you have been in the kitchen cooking — + your preparation time layering + the time the lasagna has spent baking in the oven.`. + """ + return number_of_layers + elapsed_bake_time + # TODO (student): Remember to go back and add docstrings to all your functions