Add arguments info.

This commit is contained in:
Josh Mudge 2018-12-20 13:48:53 -07:00
parent 2994c7457b
commit 23329f8275
1 changed files with 44 additions and 0 deletions

View File

@ -167,6 +167,50 @@ or if it has parameters:
greet_customer(1,ten) greet_customer(1,ten)
``` ```
# Passing Arguments
```
greet_customer(special_item):
print(special_item)
greet_customer(beef)
```
Result:
```
beef
```
## Using Keyword Arguments
Keyword arguments are nice for specifying a default but changeable argument.
Here's an example from P3, Ch2, ex7
```
def create_spreadsheet(title, row_count = 1000):
row_count = str(row_count)
print("Creating a spreadsheet called " + title + " with " + row_count +" rows.")
create_spreadsheet("Applications", row_count = 10)
```
```
row_count = 1000
```
is the default
```
row_count = 10
```
is the passed argument and thus what is used for a result:
```
Creating a spreadsheet called Applications with 10 rows.
```
# Fun Projects # Fun Projects
Design a shop using Ex7 and Ex9 as a frame: Design a shop using Ex7 and Ex9 as a frame: