What will be printed?
a = [[1, 2], [3, 4]]print(a[1][0])
1
2
3
4
list.contains(value)
list.index(value)
value in list
What will be the output?
a = [1, 2, 3]print(a + [4, 5])
[1, 2, 3, 4, 5]
[5, 7, 8]
Error
[4, 5, 1, 2, 3]
a = [1, 2, 3]a.insert(1, 10)print(a)
[1, 10, 2, 3]
[10, 1, 2, 3]
[1, 2, 10, 3]
What will be the output of the following Python code?
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 = " ")
1 2 3 4
4 5 6 7
1 3 8 12
2 5 9 13
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 = " ")
5 5 1 2 3
5 1 2 3 4
2 3 4 5 1
2 3 4 5 5
input(“Enter a string”)
eval(input(“Enter a string”))
enter(“Enter a string”)
eval(enter(“Enter a string”))
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 vprint(ttt(data[0]))
5
list1.sum(5)
list1.add(5)
listl.append(5)
list1.addelement(5)
x = ['ab', 'cd']for i in x: i.upper() print(x)
[‘ab’, ‘cd’]
[‘AB’, ‘CD’]
[None, None]
none of the mentioned
2445
133
12454
123
Appending
Concatenation
Deleting
Slicing
list1.remove("hello")
list1.remove(hello)
list1.removeAll("hello")
list1.removeOne ("hello")
list1=[1,3]list2=list1list1[0]=4print(list2)
[1, 4]
[1,3, 4]
[4,3]
[1,3]
What data type is the object below ?
L=[1, 23, 'hello', 1]
List
Dictionary
Tuple
Array
arr[-2]
arr[2]
arr[-1]
arr[1]
What is the output of following code
a = [5,2,3]print(a[5:])
[ ]
None
[3, 4, 5, 20, 5, 25, 1]
[1, 3, 3, 4, 5, 5, 20, 25]
[3, 5, 20, 5, 25, 1, 3]
[1, 3, 4, 5, 20, 5, 25]
a=[2,3,4,5]a.insert(3,1)print(a)
[3,2,3,4,5]
[2, 3, 4, 1, 5]
[2, 3,1, 4, 5]
[2, 3,3, 4, 5]
list1 = [1, 3]list2 = list1list1[0] = 4print(list2)
[1, 3]
[4, 3]
[1, 3, 4]
25
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 = elementprint(v)
6
list1.append(5)
list1.addLast(5)
list1.addEnd(5)
list1.remove(“hello”)
list1.removeAll(“hello”)
list1.removeOne(“hello”)
a = "Python"print(a[-4:-1])
tho
yth
hon
thoN
What is the correct command to shuffle the following list?
fruit=['apple', 'banana', 'papaya', 'cherry']
fruit.shuffle()
shuffle(fruit)
random.shuffle(fruit)
random.shuffleList(fruit)
pop()
delete()
remove_last()
delete_last()
a = [1,2,3]del a[1]print(a)
[1,2,3]
[2,3]
Integer
String
x = [1, 2, 3]print(x[1:10])
[2, 3]
[1, 2, 3]
[]
list=()
list.null
null.list
list=[]
a = [1, 2, 3]print(a * 2)
[2, 4, 6]
[1, 2, 3, 1, 2, 3]
[1, 4, 9]
list1 = list()
list1 = []
list1 = list([1, 2, 3])
all of the mentioned
s.__len__()
len(s)
size(s)
s.size()
What will be the output of the following Python code snippet?
a = [0, 1, 2, 3]for a[-1] in a: print(a[-1])
0 1 2 3
0 1 2 2
3 3 3 3
error
a=["Apple","Ball","Cobra"]a.sort(key=len)print(a)
[‘Apple’, ‘Ball’, ‘Cobra’]
[‘Ball’, ‘Apple’, ‘Cobra’]
[‘Cobra’, ‘Apple’, ‘Ball’]
Invalid syntax for sort()
What is the output when we execute
list("hello") ?
['h', 'e', 'l', 'l', 'o']
[' hello']
['llo']
['olleh']
names = ['Amir', 'Bear', 'Charlton', 'Daman']print(names[-1][-1])
A
Daman
n
{}
<>
()
What will be the result?
a = [1, 2, 3]print(a[1:])
[1]
[1, 2]
word1="Apple" word2="Apple" list1=[1,2,3] list2=[1,2,3] print(word1 is word2) print(list1 is list2)
True True
False True
False False
True False
x = [10, 20, 30]print(x * 0)
[0, 0, 0]
0
points = [[1, 2], [3, 1.5], [0.5, 0.5]]points.sort()print(points)
[[1, 2], [3, 1.5], [0.5, 0.5]]
[[3, 1.5], [1, 2], [0.5, 0.5]]
[[0.5, 0.5], [1, 2], [3, 1.5]]
[[0.5, 0.5], [3, 1.5], [1, 2]]
Returns None
Throws a KeyError
Creates a new key with a default value
Crashes the program
List is mutable & Tuple is immutable
List is immutable & Tuple is mutable
Both List and Tuple are Mutable
Both List and Tuple are Immutable
insert()
append()
extend()
add()
a=[1,2,3]a[::-1]print(a)
[3,2,1]
[2,1,3]
[3,1,2]
[3, 4, 5, 20, 5, 25, 1, 3]