What is the output of the following function calldef fun1(name, age=20): print(name, age) fun1('Emma', 25)Emma 25Emma 20Emma 22
Question
What is the output of the following function call?
def fun1(name, age=20):
print(name, age)
fun1('Emma', 25)
- Emma 25
- Emma 20
- Emma 22
Solution
The output of the function call fun1('Emma', 25)
will be Emma 25
.
Here's the step by step explanation:
-
The function
fun1
is defined with two parameters:name
andage
. Theage
parameter has a default value of 20. -
When you call the function with the arguments 'Emma' and 25 (
fun1('Emma', 25)
), 'Emma' is passed as thename
and 25 is passed as theage
. -
Inside the function, these values are printed. So,
Emma 25
is printed.
The other outputs Emma 20
and Emma 22
are not produced by this function call. They might be the result of other calls to the function fun1
with different arguments.
Similar Questions
What is the output of the following function calldef fun1(name, age=20): print(name, age) fun1('Emma', 25)Emma 25Emma 20Emma 22
x = 'dance'y = 'charcol'print('cold' in 3 * (x + y))What is the output of the print() function call?
What would be the output of the following Python statement?def func(i): print('Hello world', i)
What is the output of the following code snippet?def apply_func(L, func): return [func(x) for x in L]apply_func([7.1, 17.9], lambda x: x**3)
What will be the output of the following Python code?def fun(): x=15 print(x)x=12fun()Options: Pick one correct answer from belowError151215 12
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.