|
5 | 5 |
|
6 | 6 | This is a module docstring, used to describe the functionality |
7 | 7 | 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 |
9 | 11 |
|
10 | 12 |
|
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. |
12 | 15 |
|
| 16 | + :param elapsed_bake_time: int baking time already elapsed |
| 17 | + :return: int remaining bake time (in minutes) derived from 'EXPECTED_BAKE_TIME' |
13 | 18 |
|
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. |
17 | 29 |
|
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 |
20 | 32 |
|
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. |
24 | 35 | """ |
25 | 36 |
|
26 | | - pass |
| 37 | + return number_of_layers * PREPARATION_TIME |
27 | 38 |
|
28 | 39 |
|
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 |
33 | 52 |
|
34 | 53 |
|
35 | 54 |
|
|
0 commit comments