Question 1 of 25
Hints left: 3
Q1
What will be the output of the following Python code? A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] [A[row][1] for row in (0, 1, 2)]
Q2
What will be the output of the following Python code? print(list(zip((1,2,3),('a'),('xxx','yyy')))) print(list(zip((2,4),('b','c'),('yy','xx'))))
-
A
-
B
-
C
-
D
Q3
What will be the output of the following Python code snippet?
Q4
What will be the output of the following Python code snippet? print([i+j for i in "abc" for j in "def"])
-
A
-
B
-
C
-
D
Q5
What will be the output of the following Python code? >>>names = ['Amir', 'Bear', 'Charlton', 'Daman'] >>>print(names[-1][-1])
Q6
What will be the output of the following Python code? def increment_items(L, increment): i = 0 while i < len(L): L[i] = L[i] + increment i = i + 1 values = [1, 2, 3] print(increment_items(values, 2)) print(values)
-
A
-
B
-
C
-
D
Q7
What will be the output of the following Python code? l1=[10, 20, 30] l2=[-10, -20, -30] l3=[x+y for x, y in zip(l1, l2)] print(l3)
Q8
What is the output of the following code: my_list = [1, 2, 3, 4] my_list.pop() print(my_list)
Q9
To add a new element to a list we use which command?
Q10
What is the output of the following piece of code? a=list((45,)*4) print((45)*4) print(a)
-
A
-
B
-
C
-
D
Q11
What will be the output of the following Python code? A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] B = [[3, 3, 3], [4, 4, 4], [5, 5, 5]] zip(A, B)
Q12
What will be the output of the following Python code? l1=[2,4,6] l2=[-2,-4,-6] for i in zip(l1, l2): print(i)
-
A
-
B
-
C
-
D
Q13
What will be the output of the following Python code? veggies = ['carrot', 'broccoli', 'potato', 'asparagus'] veggies.insert(veggies.index('broccoli'), 'celery') print(veggies)
-
A
-
B
-
C
-
D
Q14
What is the purpose of the reverse() method for lists?
Q15
What will be the output of the following Python code? def example(L): ''' (list) -> list ''' i = 0 result = [] while i < len(L): result.append(L[i]) i = i + 3 return result
Q16
What will be the output of the following Python code? >>>list1 = [11, 2, 23] >>>list2 = [11, 2, 2] >>>list1 < list2
Q17
What will be the output of the following Python code snippet? x = [i**+1 for i in range(3)]; print(x);
Q18
What will be the output of the following Python code? a=["Apple","Ball","Cobra"] a.sort(key=len) print(a)
Q19
Which of the following Python statements will result in the output: 6? A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
Q20
What is the output of the following code: my_list = [1, 2, 3] del my_list[1] print(my_list)
Q21
Which method is used to sort the elements of a list in ascending order?
Q22
What will be the output of the following Python code? a=[1,2,3] b=a.append(4) print(a) print(b)
-
A
-
B
-
C
-
D
Q23
What will be the output of the following code: my_list = [1, 2, 3] my_list.reverse() print(my_list)
Q24
Suppose list1 is [1, 3, 2], What is list1 * 2?
-
A
-
B
-
C
-
D
Q25
What will be the output of the following Python code? l=[[1 ,2, 3], [4, 5, 6], [7, 8, 9]] [[row[i] for row in l] for i in range(3)]