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
Fixed an unclosed code block (lines 76-83), an invalid link (line 109), and a missing link (lines 85/108).
Also fixed a minor spacing issue on lines 14 and 64.
Copy file name to clipboardExpand all lines: concepts/functions/introduction.md
+8-5Lines changed: 8 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,13 +5,13 @@ Functions are used to perform specific and repetitive tasks.
5
5
6
6
More formally: a function is any Python object to which the [`function call`][calls] operation can be applied.
7
7
A function may be used to [`return`][return] one or more values as a result of some operation(s), or it may be used for one or more [`side effects`][side effects].
8
-
If a function does not specify a return value it will still return `None`.
8
+
If a function does not specify a return value it will still return `None`.
9
9
10
10
Following is an example of a function with a side effect:
11
11
12
12
```python
13
13
>>>defhello():
14
-
...print("Hello")
14
+
...print("Hello")
15
15
...
16
16
>>> hello()
17
17
Hello
@@ -28,7 +28,7 @@ The argument is used by the `print` function to know what to print.
28
28
Note that the body of the function is indented.
29
29
The indentation is important because Python relies on it to know where that block of code ends.
30
30
The function body ends at either the end of the program or just before the next line of code that is _not_ indented.
31
-
Since `hello()` does not specify a `return` value, it executes its side effect - which is calling `print()` -- and then returns `None`.
31
+
Since `hello()` does not specify a `return` value, it executes its side effect - which is calling `print()` - and then returns `None`.
32
32
Finally, we call the function by using its name and the parentheses - which signals to the Python interpreter that this is a _callable_ name.
33
33
34
34
Following is an example of a function with a return value:
@@ -61,7 +61,7 @@ Following is an example of a function which accepts an argument:
If we don't want the program to error with no argument (_but want to allow the calling code to not supply one_), we can define a [default argument][default arguments].
85
87
A default argument defines what value to use if the argument is missing when the function is called.
86
88
@@ -103,7 +105,8 @@ For more about function arguments, please see the [function arguments][function
0 commit comments