From f9f5e02c4e5615f65733ec2e2c44176c76f07776 Mon Sep 17 00:00:00 2001 From: MY-65 Date: Fri, 2 Jan 2026 23:55:24 +0200 Subject: [PATCH] Implement lasagna time calculation functions --- .../guidos-gorgeous-lasagna/lasagna.py | 49 +++++++++++++------ 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/exercises/concept/guidos-gorgeous-lasagna/lasagna.py b/exercises/concept/guidos-gorgeous-lasagna/lasagna.py index 0e1a50d571e..27da550c3fc 100644 --- a/exercises/concept/guidos-gorgeous-lasagna/lasagna.py +++ b/exercises/concept/guidos-gorgeous-lasagna/lasagna.py @@ -5,31 +5,50 @@ This is a module docstring, used to describe the functionality of a module and its functions and/or classes. -""" +"""# time the lasagna should be in the oven according to the cookbook. +EXPECTED_BAKE_TIME = 40 +PREPARATION_TIME = 2 -#TODO: define your EXPECTED_BAKE_TIME (required) and PREPARATION_TIME (optional) constants 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' -#TODO: Remove 'pass' and complete the 'bake_time_remaining()' function below. -def bake_time_remaining(): - """Calculate the bake time remaining. + 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 preparation_time_in_minutes(number_of_layers): + """Calculate the preparation time. - :param elapsed_bake_time: int - baking time already elapsed. - :return: int - remaining bake time (in minutes) derived from 'EXPECTED_BAKE_TIME'. + :param number_of_layers: int the number of lasagna layers made + :return: int amount of prep time (in minutes), based on 2 minutes per layer added - 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`. + This function takes an integer representing the number of layers added to the dish, + calculating preparation time using a time of 2 minutes per layer added. """ - pass + return number_of_layers * PREPARATION_TIME -#TODO: 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 elapsed_time_in_minutes(number_of_layers, elapsed_bake_time): + """Calculate the elapsed time. + + :param number_of_layers: int the number of layers in the lasagna + :param elapsed_bake_time: int elapsed cooking time + :return: int total time elapsed (in in minutes) preparing and cooking + + 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. + """ + + return preparation_time_in_minutes(number_of_layers) + elapsed_bake_time