4. How many elements are in m?
m = [[x, y] for x in range(0, 4) for y in range(0, 4)]
Correct Answer is : 16
5. What will be the output?
values = [[3, 4, 5, 1], [33, 6, 1, 2]] v = values[0][0]for row in range(0, len(values)): for column in range(0, len(values[row])): if v < values[row][column]: v = values[row][column] print(v)
Correct Answer is : 33
6. What will be the output?
values = [[3, 4, 5, 1], [33, 6, 1, 2]] v = values[0][0]for lst in values: for element in lst: if v > element: v = element print(v)
Correct Answer is : 1
7. What will be the output?
values = [[3, 4, 5, 1 ], [33, 6, 1, 2]] for row in values: row.sort() for element in row: print(element, end = " ") print()
Correct Answer is : The program prints two rows 1 3 4 5 followed by 1 2 6 33
8. What is the output?
matrix = [[1, 2, 3, 4], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15]] for i in range(0, 4): print(matrix[i][1], end = " ")
Correct Answer is : 2 5 9 13
9. What will be the output?
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 = " ")
Correct Answer is : 5 33
10. What will be the output?
data = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]] print(data[1][0][0])
Correct Answer is : 5
11. What will be the output?
data = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]] def ttt(m): v = m[0][0] for row in m: for element in row: if v < element: v = element return v print(ttt(data[0]))
Correct Answer is : 4
12. What will be the output?
points = [[1, 2], [3, 1.5], [0.5, 0.5]]points.sort()print(points)
Correct Answer is : [[0.5, 0.5], [1, 2], [3, 1.5]].
13. What is the output of the following code?
a=[10,23,56,[78]]
b=list(a)
a[3][0]=95
a[1]=34
print(b)
Correct Answer is : [10,23,56,[95]].
14. What does the following piece of code do?
print(list(zip((1,2,3),('a'),('xxx','yyy'))))
print(list(zip((2,4),('b','c'),('yy','xx'))))
Correct Answer is : [(1, ‘a’, ‘xxx’)].
15. What is the output of the following code?
import copy
a=[10,23,56,[78]]
b=copy.deepcopy(a)
a[3][0]=95
a[1]=34
print(b)
Correct Answer is : [10,23,56,[78]].
16. What is the output of the following piece of code?
s="[email protected]@[email protected]"
a=list(s.partition("@"))
print(a)
b=list(s.split("@",3))
print(b)
Correct Answer is : [‘a’,’@’,’[email protected]@d’].
17. What is the output of the following code?
a=[1,2,3,4]
b=[sum(a[0:x+1]) for x in range(0,len(a))]
print(b)
Correct Answer is : [1,3,6,10].
18. What is the output of the following code?
a="hello"
b=list((x.upper(),len(x)) for x in a)
print(b)