Introduction to Functions - Hsanokklis/2023-2024-Tech-journal GitHub Wiki
Functions for beginners
Calling the function:
This will print the function "hello_func"
- This is what you should not do since if you have to change the strings you would have to go in manually and change all of them.
- doing this is more efficient because if you need to change the string it will change it in all 4 of the times the function is called rather then you having to go in manually and change it all yourself.
- The return command in the functions means that when the function is called it will output the string "Hello Function"
- if you string .upper to the function it will make the text HELLO FUNCTION instead of Hello Function.
Customizing Functions with parameters
- when you set a parameter in your function your have to set the parameter when you call your function or you will get and error
A parameter is the variable listed inside the parentheses in the function definition
An argument is the value that are sent to the function when it is called
- You can specify a default for a parameter if no argument is specified when the function is called
- this is when both arguments are specified so it prints "Hi, Corey" in the terminal.