Skip to content

Commit f9f5e02

Browse files
authored
Implement lasagna time calculation functions
1 parent 608b963 commit f9f5e02

File tree

1 file changed

+34
-15
lines changed
  • exercises/concept/guidos-gorgeous-lasagna

1 file changed

+34
-15
lines changed

exercises/concept/guidos-gorgeous-lasagna/lasagna.py

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,50 @@
55
66
This is a module docstring, used to describe the functionality
77
of a module and its functions and/or classes.
8-
"""
8+
"""# time the lasagna should be in the oven according to the cookbook.
9+
EXPECTED_BAKE_TIME = 40
10+
PREPARATION_TIME = 2
911

1012

11-
#TODO: define your EXPECTED_BAKE_TIME (required) and PREPARATION_TIME (optional) constants below.
13+
def bake_time_remaining(elapsed_bake_time):
14+
"""Calculate the bake time remaining.
1215
16+
:param elapsed_bake_time: int baking time already elapsed
17+
:return: int remaining bake time (in minutes) derived from 'EXPECTED_BAKE_TIME'
1318
14-
#TODO: Remove 'pass' and complete the 'bake_time_remaining()' function below.
15-
def bake_time_remaining():
16-
"""Calculate the bake time remaining.
19+
Function that takes the actual minutes the lasagna has been in the oven as
20+
an argument and returns how many minutes the lasagna still needs to bake
21+
based on the `EXPECTED_BAKE_TIME`.
22+
"""
23+
24+
return EXPECTED_BAKE_TIME - elapsed_bake_time
25+
26+
27+
def preparation_time_in_minutes(number_of_layers):
28+
"""Calculate the preparation time.
1729
18-
:param elapsed_bake_time: int - baking time already elapsed.
19-
:return: int - remaining bake time (in minutes) derived from 'EXPECTED_BAKE_TIME'.
30+
:param number_of_layers: int the number of lasagna layers made
31+
:return: int amount of prep time (in minutes), based on 2 minutes per layer added
2032
21-
Function that takes the actual minutes the lasagna has been in the oven as
22-
an argument and returns how many minutes the lasagna still needs to bake
23-
based on the `EXPECTED_BAKE_TIME`.
33+
This function takes an integer representing the number of layers added to the dish,
34+
calculating preparation time using a time of 2 minutes per layer added.
2435
"""
2536

26-
pass
37+
return number_of_layers * PREPARATION_TIME
2738

2839

29-
#TODO: Define the 'preparation_time_in_minutes()' function below.
30-
# To avoid the use of magic numbers (see: https://en.wikipedia.org/wiki/Magic_number_(programming)), you should define a PREPARATION_TIME constant.
31-
# You can do that on the line below the 'EXPECTED_BAKE_TIME' constant.
32-
# This will make it easier to do calculations, and make changes to your code.
40+
def elapsed_time_in_minutes(number_of_layers, elapsed_bake_time):
41+
"""Calculate the elapsed time.
42+
43+
:param number_of_layers: int the number of layers in the lasagna
44+
:param elapsed_bake_time: int elapsed cooking time
45+
:return: int total time elapsed (in in minutes) preparing and cooking
46+
47+
This function takes two integers representing the number of lasagna layers and the time already spent baking
48+
and calculates the total elapsed minutes spent cooking the lasagna.
49+
"""
50+
51+
return preparation_time_in_minutes(number_of_layers) + elapsed_bake_time
3352

3453

3554

0 commit comments

Comments
 (0)