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: exercises/concept/guidos-gorgeous-lasagna/.docs/introduction.md
+20-21Lines changed: 20 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,21 +2,18 @@
2
2
3
3
Python is a [dynamic and strongly][dynamic typing in python] typed [object-oriented][object oriented programming] programming language.
4
4
It employs both [duck typing][duck typing] and [gradual typing][gradual typing], via [type hints][type hints].
5
-
Python supports Imperative, declarative (e.g. functional), and object oriented programming _styles_, but internally [everything in Python is an object][everythings an object].
6
-
7
-
This exercise introduces 4 major Python language features: Names (_variables and constants_), Functions (_and the return keyword_), Comments, and Docstrings.
5
+
Python supports Imperative, declarative (e.g., functional), and object-oriented programming _styles_, but internally [everything in Python is an object][everythings an object].
8
6
7
+
This exercise introduces 4 major Python language features: Names (_variables and constants_), Functions (_and the return keyword_), Comments, and Docstrings.
9
8
10
9
~~~~exercism/note
11
10
12
11
In general, content, tests, and analyzer tooling for the Python track follow the style conventions outlined in [PEP 8](https://www.python.org/dev/peps/pep-0008/) and [PEP 257](https://www.python.org/dev/peps/pep-0257/) for Python code style, with the additional (strong) suggestion that there be no single letter variable names.
13
12
14
13
~~~~
15
14
16
-
17
15
## Name Assignment and Re-assignment
18
16
19
-
20
17
There are no keywords in Python to define variables or constants and there is no difference in the way Python treats them.
21
18
Both are considered [_names_][facts-and-myths-about-python-names] that help programmers reference values (_objects_) in a program and are written differently only by convention.
22
19
On Exercism, [variables][variables] are always written in [`snake_case`][snake case], and _constants_ in `SCREAMING_SNAKE_CASE`.
@@ -47,14 +44,12 @@ For example, `my_first_variable` can be assigned and re-assigned many times usin
47
44
"Now, I'm a string."
48
45
```
49
46
50
-
51
47
### Constants
52
48
53
49
Constants are typically defined at a [module][module] level, being values that are accessible outside function or class scope.
54
50
Constant names **_can be reassigned to new values_**, but they are _intended_ to be named only once.
55
51
Using `SCREAMING_SNAKE_CASE` warns other programmers that these names should not be mutated or reassigned.
56
52
57
-
58
53
```python
59
54
# All caps signal that this is intended as a constant.
60
55
MY_FIRST_CONSTANT=16
@@ -64,25 +59,24 @@ MY_FIRST_CONSTANT = 16
64
59
# Please don't: MY_FIRST_CONSTANT = "Some other value"
65
60
```
66
61
67
-
68
62
## Functions
69
63
70
64
The keyword `def` begins a [function definition][function definition].
71
65
It must be followed by the function name and a parenthesized list of zero or more formal [parameters][parameters].
72
-
Parameters can be of several different varieties, and can even [vary][more on functions] in length.
66
+
Parameters can be of several different varieties, and can even [vary][more on functions] in length.
73
67
The `def` line is terminated with a colon.
74
68
75
69
```python
76
70
# function definition
77
71
defmy_function_name(parameter, second_parameter):
78
72
<function body>
79
-
73
+
80
74
```
81
75
76
+
82
77
Statements for the _body_ of the function begin on the line following `def` and must be _indented in a block_.
83
78
There is no strict indentation amount (_either space **OR**[tab] characters are acceptable_), but [indentation][indentation] must be _consistent for all indented statements_.
Docstrings are read by automated documentation tools and are returned by calling the special attribute `.__doc__` on the function, method, or class name.
223
223
Docstrings can also function as [lightweight unit tests][doctests], which will be covered in a later exercise.
224
-
They are recommended for programs of any size where documentation is needed, and their conventions are laid out in [PEP257][PEP257].
225
-
224
+
They are recommended for programs of any size where documentation is needed, and their conventions are laid out in [PEP257][pep257].
0 commit comments