Question 1 of 25
Hints left: 3
Q1
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))
Q2
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)
Q3
What will be the output of the following Python code? x = 'abcd' print(list(map(list, x)))
Q4
What is the type of each element in sys.argv?
Q5
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)
Q6
What does the nonlocal keyword do when used in a function?
Q7
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)
Q8
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]]
Q9
What will be the output of the following Python code? def say(message, times = 1): print(message * times) say('Hello') say('World', 5)
Q10
What will be the output of the following Python code? def C2F(c): return c * 9/5 + 32 print C2F(100) print C2F(0)
Q11
What will be the output of the following Python code? x = 1234 print(list(map(list, x)))
Q12
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="")
Q13
How can you pass a list to a function as an argument?
Q14
How are default arguments specified in the function heading?
Q15
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))
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? 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)
Q18
Which of these is false about recursion?
Q19
What will be the output of the following Python code? def f1(a,b=[]): b.append(a) return b print(f1(2,[3,4]))
Q20
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)
Q21
What will be the output of the following Python code? f=lambda x:bool(x%2) print(f(20), f(21))
Q22
What is the purpose of using the * symbol in function argument packing?
Q23
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))
Q24
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
Q25
How are variable length arguments specified in the function heading?