What will be the output of the following Python code snippet?
print('1.1'.isnumeric())
True
False
None
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 is the output of the following code?
a = set('dcma')b = set('mlpc')print(a^b)
{‘d’, ‘c’, ‘m’, ‘l’, ‘p’, ‘c’}
{‘m’, ‘l’, ‘p’, ‘c’}
{‘d’, ‘c’, ‘m’, ‘a’}
None of These
What will be the output of the following Python code?
print('abcdef'.partition('cd'))
(‘ab’, ‘ef’)
(‘abef’)
(‘ab’, ‘cd’, ‘ef’)
2
Built in
List
Tuple
Derived data
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.addEnd (5)
list1.addLast (5)
list1.append (5)
list1.add(5)
print('xyyxyyxyxyxxy'.replace('xy', '12', 100))
xyyxyyxyxyxxy
12y12y1212x12
none of the mentioned
print(len(a))
print(min(a))
a.remove(5)
a[2]=45
tuple1=(5,1,7,6,2)tuple1.pop(2)print(tuple1)
(5,1,6,2)
(5,1,7,6)
(5,1,7,6,2)
{1, 2, 3}
[1, 2, 3]
{}
(1, 2, 3)
What does the following slice return?
s = [0,1,2,3,4,5]print(s[1:5:2])
[1, 3]
[2, 4]
[1, 2, 3, 4]
[0, 2, 4]
print(list1[0])
print(list1[:2])
print(list1[:-2])
all of the mentioned
x | y
x ^ y
x & y
x – y
Integer
Both tuple and integer
d1 = {"john":40, "peter":45}d2 = {"john":466, "peter":45}print(d1 == d2)
More than one key isn’t allowed
Keys must be immutable
Keys must be integers
When duplicate keys encountered, the last assignment wins
What is the output of following code
x = [10, 20, 30]print(x * 0)
[0, 0, 0]
[ ]
0
What is the output?
s = "Python"print(s[-1:-4])
hon
hon in reverse
IndexError
Empty string
d = {0: 'a', 1: 'b', 2: 'c'}for i in d: print(i)
0 1 2
a b c
0 a 1 b 2 c
list1 = [1, 3]list2 = list1list1[0] = 4print(list2)
[4, 3]
[1, 4]
[1, 3, 4]
list1=[1,3]list2=list1list1[0]=4print(list2)
[1,3, 4]
[4,3]
[1,3]
d.delete(“john”:40)
d.delete(“john”)
del d[“john”]
del d(“john”:40)
What will be the output?
a = [1, 2, 3]a.insert(1, 10)print(a)
[1, 10, 2, 3]
[10, 1, 2, 3]
[1, 2, 10, 3]
Which of the following will delete key-value pair for key="tiger" in dictionary?
dic={"lion":"'wild","tiger":"'wild",'cat":"domestic","dog":"domestic"}
del dic("tiger")
dic["tiger"].delete()
delete(dic.["tiger'])
del dic["tiger"]
d1={"abc":5,"def":6,"ghi":7}print(d1[0])
abc
5
{"abc":5}
test = {1:'A', 2:'B', 3:'C'}del test[1]test[1] = 'D'del test[2]print(len(test))
Error as the key-value pair of 1:’A’ is already deleted
1
Dictionary
Set
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,
x = 'abcd'for i in x: print(i) x.upper()
a B C D
a b c d
A B C D
insert()
append()
extend()
add()
length
length()
len()
list1.shuffle()
shuffle(list1)
random.shuffle(list1)
random.shuffleList(list1)
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
anywhere in between the file
End
beginning
second line of the file
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
It returns None.
It raises an IndexError
It creates a new element at that index.
It returns an empty list.
[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]
print('abcdef12'.replace('cd', '12'))
ab12ef12
abcdef12
ab12efcd
a={1:"A",2:"B",3:"C"}print(a.items())
dict_items([(‘A’), (‘B’), (‘C’)])
dict_items([(1,2,3)])
dict_items([(1, ‘A’), (2, ‘B’), (3, ‘C’)])
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
d = {"john":40, "peter":45}print("john" in d)
matches a pattern at the start of the string.
matches a pattern at any position in the string.
such a function does not exist
set
tuple
string
string = "my name is x"for i in string: print (i, end=", ")
What is the output of the following code ?
ms = ('A','D', 'H','U','N','I','C')print(ms[1:4])
(‘D’, ‘H’, ‘U’)
(‘A’, ‘D’, ‘H’,’U’,’N’,’I’,’C’)
(‘D’,’H’,’U’,’N’,’I’,’C’)
keys()
getkeys()
allkeys()
keyvalues()
a = [1, 2, 3]b = ab.append(4)print(a)
[4]
More than one key can have the same value
The values of the dictionary can be accessed as dict[key]
Values of a dictionary must be unique
Values of a dictionary can be a mixture of letters and numbers
count()
strip()
upper()
उपरोकà¥à¤¤ सà¤à¥€