I found the suggestion in Guido’s Gorgeous Lasagna to use a PREPARATION_TIME constant confusing and can’t figure out how you could do this within the context of the problem, so I think it should be removed.
Also, for the elapsed_time_in_minutes() function, it says:
This function should return the total number of minutes you have been cooking, or the sum of your preparation time and the time the lasagna has already spent baking in the oven.
I think “cooking” should be changed to “working” since cooking implies the amount of time that lasagna has been in the oven, but we want to refer to preparation + cooking time.
(Python track maintainer here). Welcome to the Exercism forums.
Constants in Python aren’t really constants in the way final variables are in Java, or const variables are in Go.
Python’s mutable/dynamic to a fault, so a “constant” ends up as a strong convention of capitalizing the variable name, rather than something enforced by a keyword, compiler, or runtime. This can be a bit of a setup/foot-gun for those learning the language.
Constants are typically declared outside any class or function declaration (so they’re visible globally within the program), at the top of the code file or in helper files that are imported.
Because “constants” are a convention it’s really important to have this first exercise help students practice and get used to the formatting and terminology.
We did have some language about scope for constants in a previous version of this exercises introduction, but we removed it because it was creating confusion. Instead, we edited the stub file with a note of where to declare the variables.
All that being said, if you (as Jeremey asked above) could give us some detail around what was unclear/confusing in either the introduction or stub comments, with your suggestions for clarifying — that would be really helpful.
The practice or skill of preparing food by combining, mixing, and heating ingredients
…
food that has been prepared in a particular way
.
And as Jeremey has said above, the remainder of the sentence goes on to clarify that this total is made up of prep time and baking time — so I’m not inclined to change the wording at this time.
Could you explain what you found confusing about it?
The thing I find confusing is I don’t know what PREPARATION_TIME should refer to nor what to set it to.
What was your solution?
(omitting the docstring):
def preparation_time_in_minutes(number_of_layers):
result = number_of_layers * 2
return result
def elapsed_time_in_minutes(number_of_layers, elapsed_bake_time):
result = preparation_time_in_minutes(number_of_layers) + elapsed_bake_time
return result
Did you use the EXPECTED_BAKE_TIME constant? Was that clearer?
Yes, I used EXPECTED_BAKE_TIME - that was very clear from the instructions (set it to 40).
the remainder of the sentence goes on to clarify that this total is made up of prep time and baking time
The way I experienced the question for the first time is it was asking for two contradictory things (or two different things?), not a clarification. I just assumed to take the second thing that was being asked because that made the most sense.
If we don’t change the language, I’d recommend switching to saying “i.e.” or “That is” instead of “or”:
This function should return the total number of minutes you have been cooking. That is, the sum of your preparation time and the time the lasagna has already spent baking in the oven.
or
This function should return the total number of minutes you have been cooking i.e. the sum of your preparation time and the time the lasagna has already spent baking in the oven.
Looking back, I realize I’m conflating “cooking” with “baking” (the first question uses baking).
The answer to those questions is “the amount of time to prepare a single layer” and “2”. Does that make sense now that you’ve solved it?.
@BethanyG we had similar issues at the JavaScript track so we stopped expecting PREPARATION_TIME to be exported and instead added a note for mentors to discuss Magic Numbers instead.
I will take a think on the language this week. But I’m not interested in accepting a PR for it. My current rephrasing/thinking is below.
4. Calculate total elapsed time (prepping + baking) in minutes
Define the elapsed_time_in_minutes() function that takes two parameters as arguments:
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).
This 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.
We don’t test that the students define PREPARATION_TIME — solutions will pass without it. We do have a note in the stub, but it doesn’t cite magic numbers.
I was going to add a note about magic numbers here in the thread and forgot.
We could add mentor guidance for the exercise - although concept exercises aren’t really supposed to be mentored, since they’re much more targeted than the practice exercises.
I’ll take a think on whether we add a note for mentors … or maybe a clearer directive & link in the stub, rather than the existing “suggestion”.
Currently, I am leaning toward a note & link in the stub, and/or a note in the instructions.
I know I didn’t create the PR, but since my question led to the PR, could I get some reputation points? I don’t know how reputation works (is it automated or manual?), but my goal is to become a mentor here, so I’m working towards that.