Question
in Python Write your own function, named Greeter , with 2 optional parameters. The first parameter should be named Name and provide a default value
in Python
Write your own function, named Greeter, with 2 optional parameters.
The first parameter should be named Name and provide a default value of "Name". The second parameter should be named Age and provide a default value of 19.
When the function is called, print the following message to the screen if the value of Age is >= 21:
"Hello, Name. The bar is open if you care to drink."
If the value of age is < 21, instead print:
"Hello, Name. Would you like to try our new karaoke system?"
Your output should use the actual values passed as arguments to the parameters.
Example: if Meghan, 20 is passed to your function, the output should be:
"Hello, Meghan. Would you like to try our new karaoke system?"
Additionally, your submitted solution must include a main program which calls your function 2 times. Once using positional arguments. The second time using keyword arguments with the order swapped (age first, then name).
Example: if 23,Manoj is passed to your function using keyword arguments, the output should be:
"Hello, Manoj. The bar is open if you care to drink."
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started