diff --git a/Codecademy.md b/Codecademy.md index 9d86e8e..4d12d49 100644 --- a/Codecademy.md +++ b/Codecademy.md @@ -167,6 +167,50 @@ or if it has parameters: 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 Design a shop using Ex7 and Ex9 as a frame: