@@ -51,10 +51,15 @@ Functions are easy to understand, They simply **do something when they
51
51
are called** . Functions run immediately when we call them, so the
52
52
text appears on the screen right away when we run ` print(something) ` .
53
53
54
+ Sometimes people think that doing ` thingy = print('hello') ` means that
55
+ Python is going to print hello every time we type ` thingy ` . But ** this
56
+ is not correct** ! ` print('hello') ` runs print right away, and if we
57
+ type ` thingy ` later it's not going to run ` print('hello') ` again.
58
+
54
59
## Return values
55
60
56
- If we do ` thingy = print('hello') ` , what does the ` thingy ` variable end
57
- up [ pointing to ] ( variables.md#variables ) ?
61
+ Now we know that ` thingy = print('hello') ` doesn't store the
62
+ ` print('hello') ` call in a variable. But what does it do then ?
58
63
59
64
``` py
60
65
>> > thingy = print (' hello' )
64
69
>> >
65
70
```
66
71
67
- So doing ` thingy = print('hello') ` set ` thingy ` to None. Here's what
68
- happened, explained in more detail:
72
+ So doing ` thingy = print('hello') ` set ` thingy ` to None.
73
+
74
+ Here's what happened, explained in more detail:
69
75
70
- - In ` thingy = print('hello') ` , the right side is processed first.
76
+ - When we do ` thingy = print('hello') ` , the right side is processed
77
+ first.
71
78
- ` print('hello') ` calls the print function with the argument
72
79
` 'hello' ` .
73
80
- The function runs. It shows the word hello.
@@ -79,8 +86,9 @@ happened, explained in more detail:
79
86
there, and the assignment now looks like ` thingy = None ` .
80
87
- ` thingy ` is now None.
81
88
82
- Now we understand what a return value is. When we call the function,
83
- Python "replaces" ` function(args) ` with whatever the function returns.
89
+ Now we understand what ** a return value** is. When we call the
90
+ function, Python "replaces" ` function(arguments) ` with whatever the
91
+ function returns.
84
92
85
93
Calling a function without assigning the return value to anything (e.g.
86
94
` print('hello') ` instead of ` thingy = print('hello') ` ) simply throws away
0 commit comments