41
What will be the output of the following Python 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 = " ")
Answer & Solution
Answer: Option
D
42
Write a list comprehension for number and its cube for l=[1, 2, 3, 4, 5, 6, 7, 8, 9].
Answer & Solution
Answer: Option
A
43
What will be the output of the following Python code?
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
[A[i][len(A)-1-i] for i in range(len(A))]
Answer & Solution
Answer: Option
C
44
What will be the output of the following Python code?
import copy
a=[10,23,56,[78]]
b=copy.deepcopy(a)
a[3][0]=95
a[1]=34
print(b)
Answer & Solution
Answer: Option
B
45
To insert 5 to the third position in list1, we use which command?
Answer & Solution
Answer: Option
B
46
What will be the output of the following Python code snippet?
my_string = "hello world"
k = [(i.upper(), len(i)) for i in my_string]
print(k)
Answer & Solution
Answer: Option
B
47
What will be the output of the following Python code?
>>>m = [[x, x + 1, x + 2] for x in range(0, 3)]
Answer & Solution
Answer: Option
B