Welcome to level 15!
### Welcome to level 15! By the end of this lesson, you can: * Make your code shorter and more efficient by using functions. * Use functions with arguments * Use `return {value}` in functions
Remember Functions?
### Remember Functions? Functions can make your code more organized and neat, by repeating a piece of code in a function. In real python code, functions are defined with `def` then the name of the function followed by (): You do not have to use `call` to call the function, simply type the name with ().
Too much code?
### Too much code? The code below has a lot of repetition.
Use a function!
### Use a function! Now we will try to have the same output with less lines of code. For this we write a function: a piece of code we can repeat multiple times with different input.
Functions with more arguments
### Functions with more arguments The input that is in the brackets of a function we call the argument. You can use multiple arguments for one function:
Return value
### Return value Sometimes you want to use a number that has been calculated in a function outside a function. You can use the command `return` to use the value outside of the code.
Debugging
### Debugging Let's debug this code!
Let's check out the adventures!
### Let's check out the adventures! Enjoy the adventures in level 15!
Let's review!
### Let's review! What did you learn today?
Let's review!
### Let's review! Which adventure did you like best? Why? Which adventure did you like least? Why?
Show and tell!
### Show and tell! Would anyone like to show the class a program they've made?
Sneak peek into the next level...
### Sneak peek into the next level... Next level you will learn the last keyword, to make a while loop: