wd[4:]
wd[:4]
wd[-5:]
wd[:-4]
What will be the output of the following Python code snippet?
>>> 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
('abc’)
('a', 'b', 'c’)
['a', 'b', 'c’]
Error
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
What will be the output of the following Python code?
a={5,6,7,8}b={7,8,9,10} print(len(a+b))
8
Error, unsupported operand ‘+’ for sets
6
Nothing is displayed
print('1.1'.isnumeric())
True
False
None
index()
find()
Both of the above
None of the above
The values of a dictionary can be accessed using keys
The keys of a dictionary can be accessed using values
Dictionaries aren’t ordered
Dictionaries are mutable
a={1:"A",2:"B",3:"C"}b=a.copy()b[2]="D" print(a)
Error, copy() method doesn’t exist for dictionaries
{1: ‘A’, 2: ‘B’, 3: ‘C’}
{1: ‘A’, 2: ‘D’, 3: ‘C’}
“None” is printed
print(len(a))
print(min(a))
a.remove(5)
a[2]=45
print('abcdefcdghcd'.split('cd'))
[‘ab’, ‘ef’, ‘gh’]
[‘ab’, ‘ef’, ‘gh’, ”]
(‘ab’, ‘ef’, ‘gh’)
(‘ab’, ‘ef’, ‘gh’, ”)
1
9
15
list
set
tuple
dictionary
a = [0, 1, 2, 3]for a[0] in a: print(a[0])
[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]
List of tuple
Tuple of List
Array of Tuples
Invalid Type
print("abcdef".find("cd") == "cd" in "abcdef")
None of the mentioned
What does the following code print ?
x = 'mohan'for i in range (len(x)): x[i].upper()print (x)
mohan
MOHAN
None of These
Built in
List
Tuple
Derived data
print('ab cd-ef'.title())
Ab cd-ef
Ab Cd-ef
Ab Cd-Ef
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]
list1.sum(5)
list1.add(5)
listl.append(5)
list1.addelement(5)
print('Ab!2'.swapcase())
AB!@
ab12
aB!2
aB1@
a={'B':5,'A':9,'C':7}print(sorted(a))
[‘A’,’B’,’C’]
[‘B’,’C’,’A’]
[5,7,9]
[9,5,7]
print('xyyzxxyxyy'.lstrip('xyy'))
zxxyxyy
z
zxxy
d = {0, 1, 2}for x in d.values(): print(x)
0 1 2
None None None
none of the mentioned
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
>>>max("what are you")
what
y
a
Returns None
Throws a KeyError
Creates a new key with a default value
Crashes the program
What will be the output of the following code?
a=((0,2,3,4)[1:-2])print(a)
(3,)
(2, )
(1,)
(0,)
print("xyyzxyzxzxyy".endswith("xyy", 0, 2))
0
islower()
isupper()
Islower()
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():
print('abc'.islower())
list1 = [11, 2, 23]list2 = [11, 2, 2]print(list1 < list2)
values = [[3, 4, 5, 1 ], [33, 6, 1, 2]]for row in values: row.sort() for element in row: print(element, end = " ") print()
The program prints two rows 3 4 5 1 followed by 33 6 1 2
The program prints on row 3 4 5 1 33 6 1 2
The program prints two rows 1 3 4 5 followed by 1 2 6 33
empty_tuple = ()
empty_tuple = tuple()
empty_tuple = []
Both A and B
print(''.isdigit())
list1.addEnd (5)
list1.addLast (5)
list1.append (5)
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
5
4
mylist=list("a#b#c#d".split('#'))print(mylist)
[‘a’, ‘b’, ‘c’, ‘d’]
[‘a b c d’]
[‘a#b#c#d’]
[‘abcd’]
example = "helle"print(example.find("e"))
-1
String
Dictionary
list1 = [1, 3]list2 = list1list1[0] = 4print(list2)
[1, 3]
[4, 3]
[1, 4]
[1, 3, 4]
copy()
upper()
capitalize()
print('a@ 1,'.islower())
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)
3
33
str1="helloworld"print(str1[::-1])
dlrowolleh
hello
world
helloworld
print('abcdefcdghcd'.split('cd', -1))