index()
find()
Both of the above
None of the above
list.contains(value)
list.index(value)
value in list
What is the output of the following code?
a = {1:"A", 2: "B", 3: "C"}b = {4: "D", 5: "E"}a.update(b)print(a)
{1:’A’, 2: ‘B’,3: ‘C’}
{1: ‘A’, 2: ‘b’, 3: ‘c’, 4: ‘D’, 5: ‘E’}
Error
{4: ‘D’, 5: ‘E’}
What will be the output of the following Python code snippet?
x = 'abcd'for i in range(len(x)): x[i].upper()print (x)
abcd
ABCD
error
none of the mentioned
Tuple
Integer
List
Both tuple and integer
arr[-2]
arr[2]
arr[-1]
arr[1]
What will be the output of the following Python code?
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)
1
3
5
6
d1={"abc":5,"def":6,"ghi":7}print(d1[0])
abc
{"abc":5}
empty_tuple = ()
empty_tuple = tuple()
empty_tuple = []
Both A and B
a=[10,23,56,[78]] b=list(a) a[3][0]=95 a[1]=34 print(b)
[10,34,56,[95]]
[10,23,56,[78]]
[10,23,56,[95]]
[10,34,56,[78]]
Strings can be modified using indexing.
Strings are immutable.
Strings can only contain alphabetic characters.
Strings must end with a newline character.
2445
133
12454
123
print(max("what are you"))
u
t
y
dictionary()
set()
tuple()
list()
[2, 6, 4]
[1, 3, 2, 1, 3]
[1, 3, 2, 1, 3, 2]
[1, 3, 2, 3, 2, 1]
Heeeo
Heelo
Heleo
None
print('ab,12'.isalnum())
True
False
Removes an arbitrary element
Removes all the key-value pairs
Removes the key-value pair for the key given as an argument
Invalid method for dictionary
a={5,6,7,8}b={7,8,9,10} print(len(a+b))
8
Error, unsupported operand ‘+’ for sets
Nothing is displayed
A collection of ordered and mutable data
A collection of unordered and mutable data with key-value pairs
A collection of immutable key-value pairs
A collection of values only
a=["Apple","Ball","Cobra"]a.sort(key=len)print(a)
[‘Apple’, ‘Ball’, ‘Cobra’]
[‘Ball’, ‘Apple’, ‘Cobra’]
[‘Cobra’, ‘Apple’, ‘Ball’]
Invalid syntax for sort()
tuple1=(5,1,7,6,2)tuple1.pop(2)print(tuple1)
(5,1,6,2)
(5,1,7,6)
(5,1,7,6,2)
list1.add(5)
list1.append(5)
list1.addLast(5)
list1.addEnd(5)
print('a B'.isalpha())
Concatenation
Membership
Slicing
All of the above
[1, 2, 3]
(1, 2, 3)
{1, 2, 3}
{}
d = {0, 1, 2}for x in d: print(d.add(x))
0 1 2
0 1 2 0 1 2 0 1 2 …
None None None
None of the mentioned
x = "abcdef"i = "a"while i in x: x = x[1:] print(i, end = " ")
a a a a a a
a
no output
25
2
count()
upper()
strip()
All the above
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
total={}def insert(items): if items in total: total[items] += 1 else: total[items] = 1insert('Apple')insert('Ball')insert('Apple') print (len(total))
0
print("Welcome to Python".split())
[“Welcome”, “to”, “Python”]
(“Welcome”, “to”, “Python”)
{“Welcome”, “to”, “Python”}
“Welcome”, “to”, “Python”
4
a={1:"A",2:"B",3:"C"}for i in a: print(i,end=" ")
1 2 3
‘A’ ‘B’ ‘C’
1 ‘A’ 2 ‘B’ 3 ‘C’
Error, it should be: for i in a.items():
x = "abcdef"i = "a"while i in x: x = x[:-1] print(i, end = " ")
i i i i i i
a a a a a
list1.remove("hello")
list1.remove(hello)
list1.removeAll("hello")
list1.removeOne ("hello")
matches a pattern at the start of the string.
matches a pattern at any position in the string.
such a function does not exist
a={1:"A",2:"B",3:"C"}print(a.items())
Syntax error
dict_items([(‘A’), (‘B’), (‘C’)])
dict_items([(1,2,3)])
dict_items([(1, ‘A’), (2, ‘B’), (3, ‘C’)])
s.__len__()
len(s)
size(s)
s.size()
(1)
(1,)
[1]
{1}
list1 = [1, 3]list2 = list1list1[0] = 4print(list2)
[1, 3]
[4, 3]
[1, 4]
[1, 3, 4]
list1=[2, 33, 222, 14, 25]print(list1[ : -1 ])
[2, 33, 222, 14]
[25, 14, 222, 33, 2]
list
set
tuple
dict
a=[13,56,17] a.append([87]) a.extend([45,67]) print(a)
[13, 56, 17, [87], 45, 67]
[13, 56, 17, 87, 45, 67]
[13, 56, 17, 87,[ 45, 67]]
[13, 56, 17, [87], [45, 67]]
d = {0: 'a', 1: 'b', 2: 'c'}for x in d.keys(): print(d[x])
a b c
0 a 1 b 2 c
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]]
a = [0, 1, 2, 3]for a[0] in a: print(a[0])
0 1 2 3
0 1 2 2
3 3 3 3
list=()
list.null
null.list
list=[]
islower()
isupper()
Islower()