@@ -248,10 +248,10 @@ This function can be called in two ways:
248
248
arguments, because each argument has a name and it' s easy to see
249
249
which argument is which.
250
250
251
- Also note that there are no spaces around the `=` sign. That ' s
252
- because we are not assigning to a variable, we are giving the
253
- function a keyword argument and it can do whatever it wants with
254
- it .
251
+ Also note that there are no spaces around the `=` sign. This is
252
+ just a small style detail that Python programmers like to do
253
+ because `message = " hi " ` and `some_function( message = " hi " )` do two
254
+ completely different things .
255
255
256
256
Personally, I would use this function with a positional argument. It
257
257
only takes one argument, so I don' t need to worry about which argument
@@ -351,21 +351,33 @@ need to:
351
351
352
352
# # Output
353
353
354
- The built- in input function returns a value. Can our function return a
355
- value also?
354
+ The built- in input function [ returns a value](https: // github.com / Akuli / python - tutorial / blob / master / using - functions.md # return-values).
355
+ Can our function return a value also?
356
356
357
357
```py
358
358
>> > def times_two(x):
359
359
... return x * 2
360
360
...
361
361
>> > times_two(3 )
362
362
6
363
- >> > times_two(" hello " )
364
- ' hellohello '
363
+ >> > times_two(5 )
364
+ 10
365
365
>> >
366
366
```
367
367
368
- Yes, it can.
368
+ Yes, it can. Now typing `times_two(3 )` to the prompt does the same
369
+ thing as typing `6 ` to the prompt.
370
+
371
+ We can call the `times_two` function and use the result however we
372
+ want, just like we can use built- in functions:
373
+
374
+ ```py
375
+ >> > times_two(2 ) + times_two(3 ) # calculate 4 + 6
376
+ 10
377
+ >> > print (' 2 * 5 is' , times_two(5 ))
378
+ 2 * 5 is 10
379
+ >> >
380
+ ```
369
381
370
382
Note that ** returning from a function ends it immediately** .
371
383
0 commit comments