Question 1 of 25
Hints left: 3
Q1
What will be the output of the following Python code? def m(list): v = list[0] for e in list: if v < e: v = e return v values = [[3, 4, 5, 1], [33, 6, 1, 2]] for row in values: print(m(row), end = " ")
Q2
Which of the following is the correct expansion of list_1 = [expr(i) for i in list_0 if func(i)]?
Q3
What will be the output of the following Python code? A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] [A[i][i] for i in range(len(A))]
Q4
What will be the output of the following Python code? l1=[1,2,3] l2=[4,5,6] l3=[7,8,9] for x, y, z in zip(l1, l2, l3): print(x, y, z)
Q5
Suppose list1 is [3, 4, 5, 20, 5], what is list1.index(5)?
Q6
Write a list comprehension for producing a list of numbers between 1 and 1000 that are divisible by 3.
Q7
Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1.count(5)?
Q8
What will be the output of the following Python code? myList = [1, 5, 5, 5, 5, 1] max = myList[0] indexOfMax = 0 for i in range(1, len(myList)): if myList[i] > max: max = myList[i] indexOfMax = i >>>print(indexOfMax)
Q9
What will be the output of the following Python code? def unpack(a,b,c,d): print(a+d) x = [1,2,3,4] unpack(*x)
Q10
Suppose listExample is ['h','e','l','l','o'], what is len(listExample)?
Q11
What will be the output of the following Python code snippet? print([if i%2==0: i; else: i+1; for i in range(4)])
Q12
What will be the output of the following Python code? a=165 b=sum(list(map(int,str(a)))) print(b)
Q13
What will be the output of the following Python code? s=["pune", "mumbai", "delhi"] [(w.upper(), len(w)) for w in s]
-
A
-
B
-
C
-
D
Q14
What will be the output of the following Python code? values = [[3, 4, 5, 1 ], [33, 6, 1, 2]] for row in values: row.sort() for element in row: print(element, end = " ") print()
Q15
What will be the output of the following Python code? lst=[[1,2],[3,4]] print(sum(lst,[]))
Q16
What will be the output of the following Python list comprehension? [j for i in range(2,8) for j in range(i*2, 50, i)]
Q17
What will be the output of the following Python code? names1 = ['Amir', 'Bala', 'Chales'] if 'amir' in names1: print(1) else: print(2)
Q18
What will be the output of the following Python code? places = ['Bangalore', 'Mumbai', 'Delhi'] places1 = places places2 = places[:] places1[1]="Pune" places2[2]="Hyderabad" print(places)
Q19
Suppose list1 is [2445,133,12454,123], what is max(list1)?
Q20
What will be the output of the following Python code? r = [11, 12, 13, 14, 15, 16, 17, 18, 19] A = [[0, 10, 20], [30, 40, 50], [60, 70, 80]] for row in A: for col in row: r.append(col+10) r
-
A
-
B
-
C
-
D
Q21
Suppose list1 is [1, 5, 9], what is sum(list1)?
Q22
What will be the output of the following Python code? lst=[3,4,6,1,2] lst[1:2]=[7,8] print(lst)
-
A
-
B
-
C
-
D
Q23
What will be the output of the following Python code? a=[[]]*3 a[1].append(7) print(a)
Q24
Suppose list1 is [2, 33, 222, 14, 25], What is list1[:-1]?
Q25
What will be the output of the following Python code? def f(i, values = []): values.append(i) return values f(1) f(2) v = f(3) print(v)