Question 1 of 25
Hints left: 3
Q1
How are variable length arguments specified in the function heading?
Q2
What is the type of each element in sys.argv?
Q3
What will be the output of the following Python code? l=[n for n in range(5)] f=lambda x:bool(x%2) print(f(3), f(1)) for i in range(len(l)): if f(l[i]): del l[i] print(i)
Q4
What is the purpose of using the * symbol in function argument packing?
Q5
How are default arguments specified in the function heading?
Q6
What will be the output of the following Python code? def f1(a,b=[]): b.append(a) return b print(f1(2,[3,4]))
Q7
Which of these is false about recursion?
Q8
What will be the output of the following Python code? l=[1, -2, -3, 4, 5] def f1(x): return x<2 m1=filter(f1, l) print(list(m1))
Q9
What will be the output of the following code: def multiply(a, *args): result = a for num in args: result *= num return result result = multiply(2, 3, 4) print(result)
Q10
What will be the output of the following Python code? x = 'abcd' print(list(map(list, x)))
Q11
What will be the output of the following Python code? def C2F(c): return c * 9/5 + 32 print C2F(100) print C2F(0)
Q12
What will be the output of the following Python code? f=lambda x:bool(x%2) print(f(20), f(21))
Q13
What will be the output of the following Python code? def say(message, times = 1): print(message * times) say('Hello') say('World', 5)
Q14
What will be the output of the following Python code? def foo(i, x=[]): x.append(i) return x for i in range(3): print(foo(i))
Q15
What will be the output of the following Python code? import functools l=[1, 2, 3, 4, 5] m=functools.reduce(lambda x, y:x if x>y else y, l) print(m)
Q16
What happens if a local variable exists with the same name as the global variable you want to access?
Q17
What will be the output of the following Python code? odd=lambda x: bool(x%2) numbers=[n for n in range(10)] print(numbers) n=list() for i in numbers: if odd(i): continue else: break
-
A
-
B
-
C
-
D
Q18
What will be the output of the following Python code? def func(a, b=5, c=10): print('a is', a, 'and b is', b, 'and c is', c) func(3, 7) func(25, c = 24) func(c = 50, a = 100)
Q19
The single line equivalent of the following Python code? l=[1, 2, 3, 4, 5] def f1(x): return x<0 m1=filter(f1, l) print(list(m1))
Q20
Which type of copy is shown in the following python code? l1=[[10, 20], [30, 40], [50, 60]] ls=list(l1) ls [[10, 20], [30, 40], [50, 60]]
Q21
What will be the output of the following Python code? x = 1234 print(list(map(list, x)))
Q22
What will be the output of the following Python code? l=[] def convert(b): if(b==0): return l dig=b%2 l.append(dig) convert(b//2) convert(6) l.reverse() for i in l: print(i,end="")
Q23
What does the nonlocal keyword do when used in a function?
Q24
How can you pass a list to a function as an argument?
Q25
What will be the output of the following Python code? def f(x): print("outer") def f1(a): print("inner") print(a,x) f(3) f1(1)