Skip to content

Commit 4b17ffb

Browse files
authored
[Concept Docs Errors] Functions concept (#4234)
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.
1 parent fcd3f71 commit 4b17ffb

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

concepts/functions/introduction.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ Functions are used to perform specific and repetitive tasks.
55

66
More formally: a function is any Python object to which the [`function call`][calls] operation can be applied.
77
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`.
99

1010
Following is an example of a function with a side effect:
1111

1212
```python
1313
>>> def hello():
14-
... print("Hello")
14+
... print("Hello")
1515
...
1616
>>> hello()
1717
Hello
@@ -28,7 +28,7 @@ The argument is used by the `print` function to know what to print.
2828
Note that the body of the function is indented.
2929
The indentation is important because Python relies on it to know where that block of code ends.
3030
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`.
3232
Finally, we call the function by using its name and the parentheses - which signals to the Python interpreter that this is a _callable_ name.
3333

3434
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:
6161
>>> def hello(name):
6262
... return f"Hello, {name}"
6363
...
64-
>>>print(hello("Bob"))
64+
>>> print(hello("Bob"))
6565
Hello, Bob
6666

6767
```
@@ -81,6 +81,8 @@ Traceback (most recent call last):
8181
print(hello())
8282

8383
TypeError: hello() missing 1 required positional argument: 'name'
84+
```
85+
8486
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].
8587
A default argument defines what value to use if the argument is missing when the function is called.
8688

@@ -103,7 +105,8 @@ For more about function arguments, please see the [function arguments][function
103105
[arguments]: https://www.w3schools.com/python/gloss_python_function_arguments.asp
104106
[calls]: https://docs.python.org/3/reference/expressions.html#calls
105107
[def]: https://www.geeksforgeeks.org/python-def-keyword/
106-
[function arguments]: ../function-arguments/about.md
108+
[default arguments]: https://www.geeksforgeeks.org/default-arguments-in-python/
109+
[function arguments]: https://exercism.org/tracks/python/concepts/function-arguments
107110
[function]: https://docs.python.org/3/glossary.html#term-function
108111
[parameters]: https://www.codecademy.com/learn/flask-introduction-to-python/modules/learn-python3-functions/cheatsheet
109112
[return]: https://www.geeksforgeeks.org/python-return-statement/

0 commit comments

Comments
 (0)