[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 will be the output of the following Python code snippet?
print('abcefd'.replace('cd', '12'))
ab1ef2
abcefd
ab1efd
ab12ed2
arr[-2]
arr[2]
arr[-1]
arr[1]
Heeeo
Heelo
Heleo
None
What will be the output of the following Python code?
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’}
keys, keys
key values, keys
keys, key values
key values, key values
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)
Built in
List
Tuple
Derived data
Appending
Concatenation
Deleting
Slicing
[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]
anywhere in between the file
End
beginning
second line of the file
List of tuple
Tuple of List
Array of Tuples
Invalid Type
List is mutable & Tuple is immutable
List is immutable & Tuple is mutable
Both List and Tuple are Mutable
Both List and Tuple are Immutable
str1="helloworld"print(str1[::-1])
dlrowolleh
hello
world
helloworld
[3, 4, 5, 20, 5, 25, 1, 3]
[25, 20, 5, 5, 4, 3, 3, 1]
[3, 1, 25, 5, 20, 5, 4, 3]
>>> a={5,6,7}>>> sum(a,5)
5
23
18
Invalid syntax for sum method, too many arguments
What is the output of following code
a=[1,2,3]a[::-1]print(a)
[1,2,3]
[3,2,1]
[2,1,3]
[3,1,2]
What will be the output?
dict1={'a':[3,6,8]}print(len(dict1))
3
2
1
Error
x = "abcdef"i = "a"while i in x: x = x[1:] print(i, end = " ")
a a a a a a
a
no output
error
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]]
Sequence value pair
Key value pair
Tuple value pair
Record value pair
print('ab'.isalpha())
True
False
insert()
append()
extend()
add()
print("xyyzxyzxzxyy".endswith("xyy"))
>>> 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
What will be printed?
a = [1, 2, 3]print(a * 2)
[2, 4, 6]
[1, 2, 3, 1, 2, 3]
[1, 4, 9]
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,
a = [1,2,3]del a[1]print(a)
[1,3]
[2,3]
count()
upper()
strip()
All the above
d = {0: 'a', 1: 'b', 2: 'c'}for x in d.keys(): print(d[x])
0 1 2
a b c
0 a 1 b 2 c
none of the mentioned
0
4
list1.shuffle()
shuffle(list1)
random.shuffle(list1)
random.shuffleList(list1)
a={1:"A",2:"B",3:"C"}a.clear() print(a)
{ None:None, None:None, None:None}
{1:None, 2:None, 3:None}
{ }
'2+3'
'23'
None of These
print(''.isdigit())
islower()
isupper()
Islower()
print("xyyzxyzxzxyy".count('xyy', 2, 11))
Integer
Both tuple and integer
s.__len__()
len(s)
size(s)
s.size()
Dictionary
Set
None of the Above
a=[(2,4),(1,2),(3,9)]a.sort()print(a)
[(1, 2), (2, 4), (3, 9)]
[(2,4),(1,2),(3,9)]
Error because tuples are immutable
Error, tuple has no sort attribute
What is the output when we execute
list("hello") ?
['h', 'e', 'l', 'l', 'o']
[' hello']
['llo']
['olleh']
matches a pattern at the start of the string.
matches a pattern at any position in the string.
such a function does not exist
none of the mentioned.
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)
6
33
pop()
delete()
remove_last()
delete_last()
d = {1:"A", 2:"B", 1:"C"}print(d)
{1:'A',2:'B'}
{1:'C',2:'B'}
{1:'A',1:'C',2:'B'}
String
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
def f(values): values[0] = 44 v = [1, 2, 3]f(v)print(v)
[1, 44]
[1, 2, 3, 44]
[44, 2, 3]
[1, 2, 3]