How to Pass Information to a Function
We will modify our previous example to explain how you can pass
information to a function. We can do it in such a way that the program will
not only say “Welcome to Learning Python Programming” but also include
the user name. To do that, we have to request a user to enter their name.
def welcome_user(name):
“““Transmit a Welcome Message.”””
Print (“Welcome to Learning Python Programming, {name.title()}!”)
welcome_user(“Thomas”)
When we enter welcome_user(“Thomas”) it calls the function
welcome_user() and passes the name “Thomas” to the function to execute
the print command. With this, our output will be:
Welcome to Learning Python Programming, Thomas!
Do'stlaringiz bilan baham: |