list1.remove("hello")
list1.remove(hello)
list1.removeAll("hello")
list1.removeOne ("hello")
What will be the output of the following Python code?
string = "my name is x"for i in string.split(): print (i, end=", ")
m, y, , n, a, m, e, , i, s, , x,
m, y, , n, a, m, e, , i, s, , x
my, name, is, x,
error
places = ['Bangalore', 'Mumbai', 'Delhi'] places1 = places places2 = places[:] places1[1]="Pune" places2[2]="Hyderabad" print(places)
[‘Bangalore’, ‘Pune’, ‘Hyderabad’]
[‘Bangalore’, ‘Pune’, ‘Delhi’]
[‘Bangalore’, ‘Mumbai’, ‘Delhi’]
[‘Bangalore’, ‘Mumbai’, ‘Hyderabad’]
{ }
set()
[ ]
( )
list1 = [11, 2, 23]list2 = [11, 2, 2]print(list1 < list2)
True
False
Error
None
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)
Yes, list mutable and tuple immutable
No, list and tuple both are mutable
No, list and tuple both are in immutable
No, just opposite, list immutable and tuple mutable
dlroWolleH
Hello Worl
d
copy = list(original)
copy = original[:]
copy = original.copy()
All of the above
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)
19
18
17
What will be the output of the following Python code snippet?
a={1:"A",2:"B",3:"C"}a.setdefault(4,"D") print(a)
{1: ‘A’, 2: ‘B’, 3: ‘C’, 4: ‘D’}
[1,3,6,10]
a = {} a[1] = 1 a['1'] = 2 a[1.0]=4 count = 0 for i in a: count += a[i] print(count) print(a)
An exception is thrown
3
6
2
print('abcdef12'.replace('cd', '12'))
ab12ef12
abcdef12
ab12efcd
none of the mentioned
[2, 6, 4]
[1, 3, 2, 1, 3]
[1, 3, 2, 1, 3, 2]
[1, 3, 2, 3, 2, 1]
x = "abcdef"i = "a"while i in x: x = x[1:] print(i, end = " ")
a a a a a a
a
no output
count={} count[(1,2,4)] = 5 count[(4,2,1)] = 7 count[(1,2)] = 6 count[(4,2,1)] = 2 tot = 0 for i in count: tot=tot+count[i] print(len(count)+tot)
25
16
Tuples can’t be made keys of a dictionary
getkeys()
key()
keys()
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’)])
slicer
Slicing
Membership
None of these-
print('abcdefcdghcd'.split('cd', 0))
[‘abcdefcdghcd’]
‘abcdefcdghcd’
list1.shuffle()
shuffle(list1)
random.shuffle(list1)
random.shuffleList(list1)
list1.remove(“hello”)
list1.removeAll(“hello”)
list1.removeOne(“hello”)
(1)
(1,)
[1]
{1}
What is the output of the following program:
print ("Hello World"[::-1])
dlroW olleH
D
0
4
1
print('1Rn@'.lower())
n
1rn@
rn
r
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]]
myList = [1, 2, 3, 4, 5, 6]for i in range(1, 6): myList[i - 1] = myList[i] for i in range(0, 6): print(myList[i], end = " ")
2 3 4 5 6 1
6 1 2 3 4 5
2 3 4 5 6 6
1 1 2 3 4 5
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)
5
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
List
Dictionary
Set
None of the Above
>>> a={1:"A",2:"B",3:"C"}>>> del a
method del doesn’t exist for the dictionary
del deletes the values in the dictionary
del deletes the entire dictionary
del deletes the keys in the dictionary
a={1:"A",2:"B",3:"C"}b={4:"D",5:"E"}a.update(b) print(a)
{1: ‘A’, 2: ‘B’, 3: ‘C’}
Method update() doesn’t exist for dictionaries
{1: 'A', 2: 'B', 3: 'C', 4: 'D', 5: 'E'}
{4: ‘D’, 5: ‘E’}
print("abcdef".find("cd") == "cd" in "abcdef")
None of the mentioned
What data type is the object below ?
L=[1, 23, 'hello', 1]
Tuple
Array
count()
len()
index()
find()
Sequence value pair
Key value pair
Tuple value pair
Record value pair
Heeeo
Heelo
Heleo
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
What is the output of the following statement ?
print ((2, 4) + (1, 5))
(2 , 4), (4 , 5)
(3 , 9)
(2, 4, 1, 5)
Invalid Syntax
Array of tuples
List of tuples
Tuples of lists
Invalid type
example = "helle"print(example.find("e"))
-1
startswith()
startswith_prefix()
startswithwith()
startswiths()
Error, tuple slicing doesn’t exist
[2,3]
(2,3,4)
(2,3)
[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]
d = {0: 'a', 1: 'b', 2: 'c'}for x in d.values(): print(d[x])
0 1 2
a b c
0 a 1 b 2 c
d1 = {"john":40, "peter":45}d2 = {"john":466, "peter":45}print(d1 > d2)
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
print('abcdefcdgh'.partition('cd'))
(‘ab’, ‘cd’, ‘ef’, ‘cd’, ‘gh’)
(‘ab’, ‘cd’, ‘efcdgh’)
(‘abcdef’, ‘cd’, ‘gh’)