Take as many assements as you can to improve your validate your skill rating
Total Questions: 20
1. What is the output of the following code?
b=[2,3,4,5]
a=list(filter(lambda x:x%2,b))
print(a)
Correct Answer is : [3,5].
2. What is the output of the following code?
lst=[3,4,6,1,2]
lst[1:2]=[7,8]
print(lst)
Correct Answer is : [3, 7, 8, 6, 1, 2].
3. What is the output of the following code?
a=[1,2,3]
b=a.append(4)
print(a)
print(b)
Correct Answer is : [1, 2, 3, 4].
4. What will be the output when executed in python shell?
>>> a=[14,52,7]
>>>> b=a.copy()
>>> b is a
Correct Answer is : FALSE
5. What is the output of the following code?
a=[13,56,17]
a.append([87])
a.extend([45,67])
print(a)
Correct Answer is : [13, 56, 17, [87], 45, 67].
6. What is the output of the following piece of code?
a=list((45,)*4)
print((45)*4)
print(a)
Correct Answer is : 180
7. What is the output of the following code?
lst=[[1,2],[3,4]]
print(sum(lst,[]))
Correct Answer is : [1,2,3,4].
8. What is the output of the following code?
word1="Apple"
word2="Apple"
list1=[1,2,3]
list2=[1,2,3]
print(word1 is word2)
print(list1 is list2)
Correct Answer is : TRUE
9. What is the output of the following code?
def unpack(a,b,c,d):
print(a+d)
x = [1,2,3,4]
unpack(*x)
Correct Answer is : 5
10. What is the output of the following code?
places = ['Bangalore', 'Mumbai', 'Delhi']
places1 = places
places2 = places[:]
places1[1]="Pune"
places2[2]="Hyderabad"
print(places)
Correct Answer is : [‘Bangalore’, ‘Pune’, ‘Delhi’].
11. What is the output of the following piece of code?
x=[[1],[2]]
print(" ".join(list(map(str,x))))
Correct Answer is : [1] [2].
12. What is the output of the following code?
a=165
b=sum(list(map(int,str(a))))
print(b)
Correct Answer is : 12
13. What is the output of the following code?
a= [1, 2, 3, 4, 5]
for i in range(1, 5):
a[i-1] = a[i]
for i in range(0, 5):
print(a[i],end = " ")
Correct Answer is : 2 3 4 5 5
14. What is the output of the following code?
def change(var, lst):
var = 1
lst[0] = 44
k = 3
a = [1, 2, 3]
change(k, a)
print(k)
print(a)
Correct Answer is : 3
15. What is the output of the following code?
a = [1, 5, 7, 9, 9, 1]
b=a[0]
x= 0
for x in range(1, len(a)):
if a[x] > b:
b = a[x]
b= x
print(b)
Correct Answer is : 4
16. What is the output of the following code?
a=["Apple","Ball","Cobra"]
a.sort(key=len)
print(a)
Correct Answer is : [‘Ball’, ‘Apple’, ‘Cobra’].
17. What is the output of the following code?
num = ['One', 'Two', 'Three']
for i, x in enumerate(num):
print('{}: {}'.format(i, x),end=" ")
Correct Answer is : 0: One 1: Two 2: Three
18. What is the output of the following?
elements = [0, 1, 2]
def incr(x):
return x+1
print(list(map(elements, incr)))
Correct Answer is : error
19. What is the output of the following?
elements = [0, 1, 2]
def incr(x):
return x+1
print(list(map(incr, elements)))
Correct Answer is : [1, 2, 3].
20. What is the output of the following?
x = ['ab', 'cd']
print(list(map(upper, x)))