Skip to content

Commit df381d8

Browse files
authored
Touch ups and edits for clarity in instructions, introductions, hints and stub file. (exercism#3791)
1 parent 7875b77 commit df381d8

File tree

5 files changed

+74
-28
lines changed

5 files changed

+74
-28
lines changed

concepts/basics/introduction.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,26 @@
22

33
Python is a [dynamic and strongly typed][dynamic typing in python] programming language.
44
It employs both [duck typing][duck typing] and [gradual typing][gradual typing], via [type hints][type hints].
5+
Python puts a strong emphasis on code readability and (_similar to Haskell_) uses [significant indentation][significant indentation] to denote function, method, and class definitions.
6+
7+
Python was created by Guido van Rossum and first released in 1991.
58

69
Imperative, declarative (e.g., functional), and object-oriented programming _styles_ are all supported, but internally **[everything in Python is an object][everythings an object]**.
710

8-
Python puts a strong emphasis on code readability and (_similar to Haskell_) uses [significant indentation][significant indentation] to denote function, method, and class definitions.
11+
We'll dig more into what all of that means as we continue through the Python track concepts.
912

10-
Python was created by Guido van Rossum and first released in 1991.
13+
This first concept (`basics`) introduces 4 major Python language features:
14+
1. Name Assignment (_variables and constants_),
15+
2. Functions (_the `def` keyword and the `return` keyword_),
16+
3. Comments, and
17+
4. Docstrings.
1118

19+
<br>
1220

1321
## Name Assignment (Variables & Constants)
1422

1523
Programmers can bind [_names_][facts-and-myths-about-python-names] (also called _variables_) to any type of object using the assignment `=` operator: `<name> = <value>`.
16-
A name can be reassigned (or re-bound) to different values (different object types) over its lifetime.
24+
A name can be reassigned (or re-bound) to different values (different object types) over its lifetime:
1725

1826

1927
```python
@@ -37,9 +45,10 @@ A name can be reassigned (or re-bound) to different values (different object typ
3745

3846
### Constants
3947

40-
Constants are names meant to be assigned only once in a program.
41-
They should be defined at a [module][module] (file) level, and are typically visible to all functions and classes in the program.
42-
Using `SCREAMING_SNAKE_CASE` signals that the name should not be re-assigned, or its value mutated.
48+
Constants are names meant to be assigned only once in a program — although Python will not prevent re-assignment.
49+
Using `SCREAMING_SNAKE_CASE` signals to anyone reading the code that the name should **not** be re-assigned, or its value mutated.
50+
Constants should be defined at a [module][module] (file) level, and are typically visible to all functions and classes in a program.
51+
4352

4453

4554
## Functions
@@ -92,7 +101,9 @@ def add_two_numbers(number_one, number_two):
92101
11
93102
```
94103

104+
95105
Functions that do not have an _explicit_ `return` expression will _implicitly_ return the [`None`][none] object.
106+
This means that if you do not use `return` in a function, Python will return the `None` object for you.
96107
The details of `None` will be covered in a later exercise.
97108
For the purposes of this exercise and explanation, `None` is a placeholder that represents nothing, or null:
98109

exercises/concept/guidos-gorgeous-lasagna/.docs/hints.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111
## 1. Define expected bake time in minutes
1212

13-
- You need to [name][naming] a constant, and [assign][assignment] it an [integer][numbers] value.
13+
- You need to [name][naming] a [constant][constants], and [assign][assignment] it an [integer][numbers] value.
14+
This constant should be the first thing after the docstring that is at the top of the file.
15+
Remember to remove the #TODO comment after defining the constant.
1416

1517
## 2. Calculate remaining bake time in minutes
1618

@@ -38,6 +40,7 @@
3840

3941
[assignment]: https://docs.python.org/3/reference/simple_stmts.html#grammar-token-assignment-stmt
4042
[comments]: https://realpython.com/python-comments-guide/
43+
[constants]: https://stackoverflow.com/a/2682752
4144
[defining functions]: https://docs.python.org/3/tutorial/controlflow.html#defining-functions
4245
[docstrings]: https://docs.python.org/3/tutorial/controlflow.html#tut-docstrings
4346
[naming]: https://realpython.com/python-variables/

exercises/concept/guidos-gorgeous-lasagna/.docs/instructions.md

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,70 @@ You're going to write some code to help you cook a gorgeous lasagna from your fa
44

55
You have five tasks, all related to cooking your recipe.
66

7-
## 1. Define expected bake time in minutes
7+
<br>
88

9-
Define an `EXPECTED_BAKE_TIME` constant that returns how many minutes the lasagna should bake in the oven.
9+
~~~~exercism/note
10+
We have started the first function definition for you in the stub file, but you will need to write the remaining function definitions yourself.
11+
You will also need to define any constants yourself.
12+
Read the #TODO comment lines in the stub file carefully.
13+
Once you are done with a task, remove the TODO comment.
14+
~~~~
15+
16+
<br>
17+
18+
## 1. Define expected bake time in minutes as a constant
19+
20+
Define the `EXPECTED_BAKE_TIME` [constant][constants] that represents how many minutes the lasagna should bake in the oven.
1021
According to your cookbook, the Lasagna should be in the oven for 40 minutes:
1122

1223
```python
13-
>>> import lasagna
14-
>>> lasagna.EXPECTED_BAKE_TIME
24+
>>> print(EXPECTED_BAKE_TIME)
1525
40
1626
```
1727

1828
## 2. Calculate remaining bake time in minutes
1929

20-
Implement 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`.
30+
Complete 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` constant.
2131

2232
```python
23-
>>> from lasagna import bake_time_remaining
2433
>>> bake_time_remaining(30)
2534
10
2635
```
2736

37+
2838
## 3. Calculate preparation time in minutes
2939

30-
Implement the `preparation_time_in_minutes(number_of_layers)` function that takes the number of layers you want to add to the lasagna as an argument and returns how many minutes you would spend making them.
40+
Define the `preparation_time_in_minutes()` [function][functions] that takes the `number_of_layers` you want to add to the lasagna as an argument and returns how many minutes you would spend making them.
3141
Assume each layer takes 2 minutes to prepare.
3242

3343
```python
34-
>>> from lasagna import preparation_time_in_minutes
44+
>>> def preparation_time_in_minutes(number_of_layers):
45+
...
46+
...
47+
3548
>>> preparation_time_in_minutes(2)
3649
4
3750
```
3851

52+
3953
## 4. Calculate total elapsed cooking time (prep + bake) in minutes
4054

41-
Implement the `elapsed_time_in_minutes(number_of_layers, elapsed_bake_time)` function that has two parameters: `number_of_layers` (_the number of layers added to the lasagna_) and `elapsed_bake_time` (_the number of minutes the lasagna has been baking in the oven_).
42-
This function should return the total number of minutes you've been cooking, or the sum of your preparation time and the time the lasagna has already spent baking in the oven.
55+
Define the `elapsed_time_in_minutes()` function that takes two parameters as arguments: `number_of_layers` (_the number of layers added to the lasagna_) and `elapsed_bake_time` (_the number of minutes the lasagna has been baking in the oven_).
56+
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.
4357

4458
```python
45-
>>> from lasagna import elapsed_time_in_minutes
59+
>>> def elapsed_time_in_minutes(number_of_layers, elapsed_bake_time):
60+
...
61+
...
62+
4663
>>> elapsed_time_in_minutes(3, 20)
4764
26
4865
```
4966

67+
5068
## 5. Update the recipe with notes
5169

52-
Go back through the recipe, adding "notes" in the form of function docstrings.
70+
Go back through the recipe, adding "notes" in the form of [function docstrings][function-docstrings].
5371

5472
```python
5573
def elapsed_time_in_minutes(number_of_layers, elapsed_bake_time):
@@ -64,3 +82,7 @@ def elapsed_time_in_minutes(number_of_layers, elapsed_bake_time):
6482
lasagna.
6583
"""
6684
```
85+
86+
[constants]: https://stackoverflow.com/a/2682752
87+
[functions]: https://docs.python.org/3/tutorial/controlflow.html#defining-functions
88+
[function-docstrings]: https://docs.python.org/3/tutorial/controlflow.html#documentation-strings

exercises/concept/guidos-gorgeous-lasagna/.docs/introduction.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This first exercise introduces 4 major Python language features:
1414
3. Comments, and
1515
4. Docstrings.
1616

17+
<br>
1718

1819
~~~~exercism/note
1920
@@ -25,6 +26,7 @@ On the Python track, [variables][variables] are always written in [`snake_case`]
2526
[snake case]: https://en.wikipedia.org/wiki/Snake_case
2627
~~~~
2728

29+
<br>
2830

2931
## Name Assignment (Variables & Constants)
3032

@@ -33,21 +35,21 @@ A name can be reassigned (or re-bound) to different values (different object typ
3335

3436

3537
```python
36-
>>> my_first_variable = 1 # my_first_variable bound to an integer object of value one.
37-
>>> my_first_variable = 2 # my_first_variable re-assigned to integer value 2.
38+
>>> my_first_variable = 1 #<-- my_first_variable bound to an integer object of value one.
39+
>>> my_first_variable = 2 #<-- my_first_variable re-assigned to integer value 2.
3840

3941
>>> print(type(my_first_variable))
4042
<class 'int'>
4143

4244
>>> print(my_first_variable)
4345
2
4446

45-
>>> my_first_variable = "Now, I'm a string." # You may re-bind a name to a different object type and value.
47+
>>> my_first_variable = "Now, I'm a string." #<-- You may re-bind a name to a different object type and value.
4648
>>> print(type(my_first_variable))
4749
<class 'str'>
4850

4951
>>> print(my_first_variable)
50-
"Now, I'm a string." # Strings can be declared using single or double quote marks.
52+
"Now, I'm a string." #<-- Strings can be declared using single or double quote marks.
5153
```
5254

5355

@@ -90,10 +92,11 @@ IndentationError: unindent does not match any outer indentation level
9092

9193
Functions _explicitly_ return a value or object via the [`return`][return] keyword:
9294

95+
9396
```python
9497
# Function definition on first line, explicit return used on final line.
95-
def add_two_numbers(number_one, number_two):
96-
return number_one + number_two
98+
>>> def add_two_numbers(number_one, number_two):
99+
return number_one + number_two
97100

98101

99102
# Calling the function in the Python terminal returns the sum of the numbers.
@@ -109,6 +112,7 @@ def add_two_numbers(number_one, number_two):
109112

110113

111114
Functions that do not have an _explicit_ `return` expression will _implicitly_ return the [`None`][none] object.
115+
This means that if you do not use `return` in a function, Python will return the `None` object for you.
112116
The details of `None` will be covered in a later exercise.
113117
For the purposes of this exercise and explanation, `None` is a placeholder that represents nothing, or null:
114118

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99

1010

11-
#TODO: define the 'EXPECTED_BAKE_TIME' constant.
11+
#TODO: define the 'EXPECTED_BAKE_TIME' constant below.
1212

1313

1414
#TODO: Remove 'pass' and complete the 'bake_time_remaining()' function below.
@@ -27,9 +27,15 @@ def bake_time_remaining():
2727

2828

2929
#TODO: Define the 'preparation_time_in_minutes()' function below.
30-
# You might also consider using 'PREPARATION_TIME' here, if you have it defined.
30+
# You might also consider defining 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.
3133

3234

3335

3436
#TODO: define the 'elapsed_time_in_minutes()' function below.
35-
# Remember to add a docstring (you can copy and then alter the one from bake_time_remaining.)
37+
38+
39+
40+
# TODO: Remember to go back and add docstrings to all your functions
41+
# (you can copy and then alter the one from bake_time_remaining.)

0 commit comments

Comments
 (0)