What is the output of following code
a = [5,2,3]print(a[5:])
Error
[ ]
None
5
list1.remove(“hello”)
list1.remove(hello)
list1.removeAll(“hello”)
list1.removeOne(“hello”)
[‘h’, ‘e’, ‘l’, ‘l’, ‘o’]
[‘hello’]
[‘llo’]
[‘olleh’]
What will be the output of the following Python code?
a=[1,2,3] b=a.append(4) print(a) print(b)
[1,2,3,4] [1,2,3,4]
[1, 2, 3, 4] None
Syntax error
[1,2,3] [1,2,3,4]
What is the output when we execute
list("hello") ?
['h', 'e', 'l', 'l', 'o']
[' hello']
['llo']
['olleh']
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]))
1
2
4
What is the output of the following code:
L=['a','b','c','d']print ( "".join(L))
abcd
[‘a’,’b’,’c’,’d’]
Row 1
Column 2
Element at row 1, column 2
Entire second row
list1.remove("hello")
list1.removeAll("hello")
list1.removeOne ("hello")
what is the output of the following code?
M=['b' *x for x in range(4)] print(M)
['', 'b', 'bb', 'bbb']
['b,'bb', "bbb', "bbbb']
['b','bb', bbb']
none of these
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)
3
6
pop()
delete()
remove_last()
delete_last()
list1 = [1, 3]list2 = list1list1[0] = 4print(list2)
[1, 3]
[4, 3]
[1, 4]
[1, 3, 4]
What will be printed?
a = [1, 2, 3]print(a * 2)
[2, 4, 6]
[1, 2, 3, 1, 2, 3]
[1, 4, 9]
Heeeo
Heelo
Heleo
a = [[1, 2], [3, 4]]print(a[1][0])
input(“Enter a string”)
eval(input(“Enter a string”))
enter(“Enter a string”)
eval(enter(“Enter a string”))
x = [1, 2, 3]print(x[1:10])
[2, 3]
[1, 2, 3]
[]
Appending
Concatenation
Deleting
Slicing
list1 = [11, 2, 23]list2 = [11, 2, 2]print(list1 < list2)
True
False
0
list.contains(value)
list.index(value)
value in list
[3, 4, 5, 20, 5, 25, 1, 3]
[1, 3, 3, 4, 5, 5, 20, 25]
[3, 5, 20, 5, 25, 1, 3]
[1, 3, 4, 5, 20, 5, 25]
arr[-2]
arr[2]
arr[-1]
arr[1]
[3, 4, 5, 20, 5, 25, 1, 3, 34, 5]
[1, 3, 3, 4, 5, 5, 20, 25, 34, 5]
[25, 20, 5, 5, 4, 3, 3, 1, 34, 5]
[1, 3, 4, 5, 20, 5, 25, 3, 34, 5]
What is the output of following?
lst = [1, 2, 3, 4]print(lst[::-1])
[1, 2, 3, 4]
[4, 3, 2, 1]
[3, 4, 5, 20, 5, 25, 1]
a = "Python"print(a[-4:-1])
tho
yth
hon
thoN
list1.add(5)
list1.append(5)
list1.addLast(5)
list1.addEnd(5)
[25, 20, 5, 5, 4, 3, 3, 1]
[3, 1, 25, 5, 20, 5, 4, 3]
list1.sum(5)
listl.append(5)
list1.addelement(5)
Returns None
Throws a KeyError
Creates a new key with a default value
Crashes the program
9
15
What will be the output of the following code snippet?
a=[1,2,3,4,5,6,7,8,9]a[::2]=10,20,30,40,50,60print(a)
ValueError: attempt to assign sequence of size 6 to extended slice of size 5
[10, 2, 20, 4, 30, 6, 40, 8, 50, 60]
[1, 2, 10, 20, 30, 40, 50, 60]
[1, 10, 3, 20, 5, 30, 7, 40, 9, 50, 60]
Tuple
Integer
String
List
25
What will be the output of the following ?
print((range(4)))
0,1,2,3
[0,1,2,3]
range(0, 4)
(0,1,2,3)
list1.addEnd (5)
list1.addLast (5)
list1.append (5)
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)
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
List is mutable & Tuple is immutable
List is immutable & Tuple is mutable
Both List and Tuple are Mutable
Both List and Tuple are Immutable
a=[1,2,3]a[::-1]print(a)
[1,2,3]
[3,2,1]
[2,1,3]
[3,1,2]
s.__len__()
len(s)
size(s)
s.size()
What will be the output of the following code?
list1=[2,33,222,14,25]print(list1[-1])
33
14
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 = " ")
3 33
1 1
5 6
5 33
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)
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]