You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: concepts/basics/introduction.md
+17-6Lines changed: 17 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,18 +2,26 @@
2
2
3
3
Python is a [dynamic and strongly typed][dynamic typing in python] programming language.
4
4
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.
5
8
6
9
Imperative, declarative (e.g., functional), and object-oriented programming _styles_ are all supported, but internally **[everything in Python is an object][everythings an object]**.
7
10
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.
9
12
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.
11
18
19
+
<br>
12
20
13
21
## Name Assignment (Variables & Constants)
14
22
15
23
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:
17
25
18
26
19
27
```python
@@ -37,9 +45,10 @@ A name can be reassigned (or re-bound) to different values (different object typ
37
45
38
46
### Constants
39
47
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.
Copy file name to clipboardExpand all lines: exercises/concept/guidos-gorgeous-lasagna/.docs/instructions.md
+34-12Lines changed: 34 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,52 +4,70 @@ You're going to write some code to help you cook a gorgeous lasagna from your fa
4
4
5
5
You have five tasks, all related to cooking your recipe.
6
6
7
-
## 1. Define expected bake time in minutes
7
+
<br>
8
8
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.
10
21
According to your cookbook, the Lasagna should be in the oven for 40 minutes:
11
22
12
23
```python
13
-
>>>import lasagna
14
-
>>> lasagna.EXPECTED_BAKE_TIME
24
+
>>>print(EXPECTED_BAKE_TIME)
15
25
40
16
26
```
17
27
18
28
## 2. Calculate remaining bake time in minutes
19
29
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.
21
31
22
32
```python
23
-
>>>from lasagna import bake_time_remaining
24
33
>>> bake_time_remaining(30)
25
34
10
26
35
```
27
36
37
+
28
38
## 3. Calculate preparation time in minutes
29
39
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.
## 4. Calculate total elapsed cooking time (prep + bake) in minutes
40
54
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.
0 commit comments