dlroWolleH
Hello Worl
d
Error
Tuple
Integer
List
Both tuple and integer
[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]
Sequence value pair
Key value pair
Tuple value pair
Record value pair
count()
len()
index()
find()
What will be the output of the following Python code?
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]]
s2.issubset(s1)
s2.issuperset(s1)
s1.issuperset(s2)
s1.isset(s2)
What will be the output of the following Python code snippet?
print('abcdefcdghcd'.split('cd', -1))
[‘ab’, ‘ef’, ‘gh’]
[‘ab’, ‘ef’, ‘gh’, ”]
(‘ab’, ‘ef’, ‘gh’)
(‘ab’, ‘ef’, ‘gh’, ”)
print('ab cd-ef'.title())
Ab cd-ef
Ab Cd-ef
Ab Cd-Ef
None of the mentioned
Error, tuple slicing doesn’t exist
[2,3]
(2,3,4)
(2,3)
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
What will be the output of the following expression?
a = 2b = 8print(a|b )print(a >> 1)
10 0
10 2
2 2
10 1
print('abcd'.partition('cd'))
(‘ab’, ‘cd’, ”)
(‘ab’, ‘cd’)
error
none of the mentioned
remove
pop
discard
dispose
d.size()
len(d)
size(d)
d.len()
delete all the trailing whitespace characters
delete all the leading whitespace characters
delete all the leading and trailing whitespace characters
delete upper case characters
mylist=list("a#b#c#d".split('#'))print(mylist)
[‘a’, ‘b’, ‘c’, ‘d’]
[‘a b c d’]
[‘a#b#c#d’]
[‘abcd’]
append()
insert()
remove()
Concatenation
Membership
Slicing
All of the above
print(''.isdigit())
True
False
None
print("xyyzxyzxzxyy".count('yy', 1))
2
0
1
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)
Returns None
Throws a KeyError
Creates a new key with a default value
Crashes the program
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
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
x | y
x ^ y
x & y
x – y
str1[ : : -1 ]
str1[ : : 1 ]
str1[ : -1 : -1 ]
d = {"john":40, "peter":45}print(list(d.keys()))
[“john”, “peter”]
[“john”:40, “peter”:45]
(“john”, “peter”)
(“john”:40, “peter”:45)
print("abcdef".find("cd"))
3
String
Dictionary
print('abcdef12'.replace('cd', '12'))
ab12ef12
abcdef12
ab12efcd
Removes all spaces from the string.
Removes the first and last character of the string.
Removes whitespace from the beginning and end of the string.
Converts the string into a list of characters.
print('abcdefcdgh'.partition('cd'))
(‘ab’, ‘cd’, ‘ef’, ‘cd’, ‘gh’)
(‘ab’, ‘cd’, ‘efcdgh’)
(‘abcdef’, ‘cd’, ‘gh’)
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]
{1: ‘A’, 2: ‘B’}
dict([[1,”A”],[2,”B”]])
{1,”A”,2”B”}
{ }
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]
getkeys()
key()
keys()
upper()
strip()
All the above
list
set
tuple
dictionary
[3, 4, 5, 20, 5, 25, 1, 3]
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
arr[-2]
arr[2]
arr[-1]
arr[1]
list.contains(value)
list.index(value)
value in list
print('xyyzxxyxyy'.lstrip('xyy'))
zxxyxyy
z
zxxy
print('abcdef'.partition('cd'))
(‘ab’, ‘ef’)
(‘abef’)
(‘ab’, ‘cd’, ‘ef’)
उपरोकà¥à¤¤ सà¤à¥€
4
What is the output when we execute
list("hello") ?
['h', 'e', 'l', 'l', 'o']
[' hello']
['llo']
['olleh']
print('abc'.islower())