What if we want the function to do something different depending on the parameters we provide? Remember that you can change the number of seconds Zumi drives forward in zumi.forward(). You can also add parameters to your functions!
In [ ]:
def greet_user(name):
print("Hello", name)
greet_user("Zumi")
We’ve modified the function definition to say “hello” to whichever name is provided as a parameter. In the example, we pass “Zumi” as a parameter to the function. Try calling the function again, but with a different name. Make sure it’s in quotation marks!
In [ ]:
greet_user("CHANGE ME!")
What do you think would happen if there weren’t any quotation marks in the function call? Or if we put numbers?
In [ ]:
greet_user(12345)
Since we defined the function to print to the screen, any input needs to be in quotation marks. That does not mean you can’t write functions that can use numbers! Most of Zumi’s parameters, like speed and duration, are numbers.