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
[Basics, Conditionals, and List Methods]: Corrected Typos, Formatting, & Grammar Issues (exercism#4179)
* Corrected typos, formatting, and grammar issues for basics, conditionals, and list-methods.
* Further corrections from code review.
* More typos.
* Fixed double quote issue.
Copy file name to clipboardExpand all lines: concepts/basics/about.md
+43-32Lines changed: 43 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,16 +64,16 @@ For example, `my_first_variable` can be re-assigned many times using `=`, and ca
64
64
>>>print(my_first_variable)
65
65
2
66
66
67
-
>>> my_first_variable ="Now, I'm a string."# You may re-bind a name to a different object type and value.
67
+
>>> my_first_variable ="Now, I'm a string."#<--You may re-bind a name to a different object type and value.
68
68
>>>print(type(my_first_variable))
69
69
<class'str'>
70
70
71
-
>>> my_first_variable ='You can call me "str".'# Strings can be declared using single or double quote marks.
71
+
>>> my_first_variable ='You can call me "str".'#<--Strings can be declared using single or double quote marks.
72
72
>>>print(my_first_variable)
73
73
You can call me "str".
74
74
75
-
import collections
76
-
>>> my_first_variable = collections.Counter([1,1,2,3,3,3,4,5,6,7]) # Now my_first_variable has been re-bound to a Counter object.
75
+
>>>import collections
76
+
>>> my_first_variable = collections.Counter([1,1,2,3,3,3,4,5,6,7]) #<--Now my_first_variable has been re-bound to a Counter object.
77
77
>>>print(type(my_first_variable))
78
78
<class'collections.Counter'>
79
79
@@ -102,7 +102,7 @@ MY_FIRST_CONSTANT = "Some other value"
102
102
103
103
## Functions
104
104
105
-
In Python, units of functionality are encapsulated in [_functions._][functions], which are themselves [objects][objects] (_it's [turtles all the way down][turtles all the way down]_).
105
+
In Python, units of functionality are encapsulated in [_functions_][functions], which are themselves [objects][objects] (_it's [turtles all the way down][turtles all the way down]_).
106
106
107
107
Functions can be executed by themselves, passed as arguments to other functions, nested, or bound to a class.
108
108
When functions are bound to a [class][classes] name, they're referred to as [methods][method objects].
@@ -114,7 +114,7 @@ Statements for the _body_ of the function begin on the line following `def` and
114
114
115
115
116
116
```python
117
-
# The body of a function is indented by 2 spaces, & prints the sum of the numbers.
117
+
# The body of a function is indented by 2 spaces & prints the sum of the numbers.
Functions that do not have an _explicit_ expression following a `return` will _implicitly_ return the [`None`][none] object.
107
-
The details of `None` will be covered in a later exercise.
107
+
The details of `None` will be covered in a later concept.
108
108
For the purposes of this exercise and explanation, `None` is a placeholder that represents nothing, or null:
109
109
110
110
111
111
```python
112
-
113
112
# This function will return `None`
114
113
defsquare_a_number(number):
115
114
square = number * number
@@ -131,8 +130,7 @@ Functions that omit `return` will also _implicitly_ return the [`None`][none] o
131
130
This means that if you do not use `return` in a function, Python will return the `None` object for you.
132
131
133
132
```python
134
-
135
-
# This function omits a return keyword altogether
133
+
# This function omits a return keyword altogether.
136
134
defadd_two_numbers(number_one, number_two):
137
135
result = number_one + number_two
138
136
@@ -158,29 +156,35 @@ Each line of a comment block must start with the `#` character.
158
156
## Docstrings
159
157
160
158
The first statement of a function body can optionally be a [_docstring_][docstring], which concisely summarizes the function or object's purpose.
161
-
Docstring conventions are laid out in [PEP257][pep257].
159
+
Docstrings are read by automated documentation tools such as [Sphinx][sphinx] and are returned by calling the special attribute `.__doc__` on the function, method, or class name.
160
+
General docstring conventions are laid out in [PEP257][pep257], but exact formats will vary by project and team.
162
161
Docstrings are declared using triple double quotes (""") indented at the same level as the code block:
163
162
164
163
165
164
```python
166
-
167
-
# An example from PEP257 of a multi-line docstring.
165
+
# An example from PEP257 of a multi-line docstring
166
+
# reformatted to use Google style non-type hinted docstrings.
167
+
# Some additional details can be found in the Sphinx documentation:
0 commit comments