Add Parameters
Challenge 2-1: Functions
Challenge 2-1: Functions
Now let's define a function with parameters (also called arguments):
>>> def say_hello(myname):
print('Hello', myname)
This time, when we call our function, we need to pass it a value - we'll put the string "Batman" inside the parentheses:
>>> say_hello("Batman")
Hello Batman
What does the function do if we give it a different string?
>>> say_hello("Sarah")
Hello Sarah
See how we can make our function do different things just by passing in different arguments?
What happens if we pass our function a number? Or some other type of data?