Question 1 of 25
Hints left: 3
Q1
What is the output of the following code: def greet(name): print(f"Hello, {name}!") greet("Alice")
Q2
What is the purpose of the return statement in a function?
Q3
What will be the output of the following Python code? min = (lambda x, y: x if x < y else y) min(101*99, 102*98)
Q4
What will be the output of the following Python code? def fun(n): if (n > 100): return n - 5 return fun(fun(n+11)); print(fun(45))
Q5
What will be the output of the following Python code? l1=[1, 2, 3, [4]] l2=list(l1) id(l1)==id(l2)
Q6
What will be the output of the following Python code? list(map((lambda x:x**2), filter((lambda x:x%2==0), range(10))))
-
A
-
B
-
C
-
D
Q7
What is a variable defined outside a function referred to as?
Q8
What will be the output of the following Python code? def cube(x): return x * x * x x = cube(3) print x
Q9
What does the *args syntax in a function definition mean?
Q10
What will be the output of the following Python code? def display(b, n): while n > 0: print(b,end="") n=n-1 display('z',3)
Q11
What will be the output of the following Python code? x = [[0], [1]] print(len(' '.join(list(map(str, x)))))
Q12
Fill in the line of the following Python code for calculating the factorial of a number. def fact(num): if num == 0: return 1 else: return _____________________
Q13
What will be the output of the following Python code? x = ['ab', 'cd'] print(len(list(map(list, x))))))
Q14
The nested list undergoes shallow copy even when the list as a whole undergoes deep copy.
Q15
What will be the output of the following Python code? x = [34, 56] print((''.join(list(map(str, x))),))
Q16
What will be the output of the following Python code? def sum(*args): '''Function returns the sum of all values''' r = 0 for i in args: r += i return r print sum.__doc__ print sum(1, 2, 3) print sum(1, 2, 3, 4, 5)
Q17
Where are the arguments received from the command line stored?
Q18
What will be the output of the following Python code? def foo(fname, val): print(fname(val)) foo(max, [1, 2, 3]) foo(min, [1, 2, 3])
Q19
What is the purpose of using the ** symbol in function argument unpacking?
Q20
What is the purpose of a docstring in a function?
Q21
How are keyword arguments specified in the function heading?
Q22
What will be the output of the following Python code? def f1(): global x x+=1 print(x) x=12 print("x")
Q23
What is the purpose of using recursion in a function?
Q24
What will be the output of the following Python code? l1=[10, 20, 30] l2=l1 id(l1)==id(l2) l2=l1.copy() id(l1)==id(l2)
Q25
What is the purpose of a function in Python?