What will be the output of the following Python code snippet?
d = {"john":40, "peter":45}print(d["john"])
40
45
“john”
“peter”
list.contains(value)
list.index(value)
value in list
{1: ‘A’, 2: ‘B’}
dict([[1,”A”],[2,”B”]])
{1,”A”,2”B”}
{ }
pop
remove
update
sum
[‘h’, ‘e’, ‘l’, ‘l’, ‘o’]
[‘hello’]
[‘llo’]
[‘olleh’]
insert()
append()
extend()
add()
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
print('Hello!2@#World'.istitle())
True
False
None
d = {}
d = {“john”:40, “peter”:45}
d = {40:”john”, 45:”peter”}
All of the mentioned
a={1:5,2:3,3:4}a.pop(3) print(a)
{1: 5}
{1: 5, 2: 3}
Error, syntax error for pop() method
{1: 5, 3: 4}
print('1Rn@'.lower())
n
1rn@
rn
r
print("xyyzxyzxzxyy".endswith("xyy", 0, 2))
0
1
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
t1=1,2,4
t1=(1,)
t1=tuple(“123”)
All of these
What data type is the object below ?
L=[1, 23, 'hello', 1]
List
Dictionary
Tuple
Array
print('cd'.partition('cd'))
(‘cd’)
(”)
(‘cd’, ”, ”)
(”, ‘cd’, ”)
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]
23
'2+3'
'23'
None of These
print('abcdefcdghcd'.split('cd', -1))
[‘ab’, ‘ef’, ‘gh’]
[‘ab’, ‘ef’, ‘gh’, ”]
(‘ab’, ‘ef’, ‘gh’)
(‘ab’, ‘ef’, ‘gh’, ”)
print(len(a))
print(min(a))
a.remove(5)
a[2]=45
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
space
colon
semi colon
What will be the output of following statement ?
>>>"m"+"n1"
'm+nl'
'mn1'
'm n1'
'm'
indexing
Replication
concatenation
None of the Above
x = "abcdef"i = "a"while i in x: x = x[1:] print(i, end = " ")
a a a a a a
a
no output
print("xyyzxyzxzxyy".count('xyy', 2, 11))
2
Slicing
Concatenation
Deletion of elements
Iteration
d.delete(“john”:40)
d.delete(“john”)
del d[“john”]
del d(“john”:40)
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
List of tuple
Tuple of List
Array of Tuples
Invalid Type
print('xyyzxxyxyy'.lstrip('xyy'))
zxxyxyy
z
zxxy
In Python, a tuple can contain only integers as its elements.
In Python, a tuple can contain only strings as its elements.
In Python, a tuple can contain both integers and strings as its elements.
In Python, a tuple can contain either string or integer but not both at a time.
Since “susan” is not a value in the set, Python raises a KeyError exception
It is executed fine and no exception is raised, and it returns None
Since “susan” is not a key in the set, Python raises a KeyError exception
Since “susan” is not a key in the set, Python raises a syntax error
index()
find()
Both of the above
None of the above
print("xyyzxyzxzxyy".count('xyy', -10, -1))
pop()
delete()
remove_last()
delete_last()
print("xyyzxyzxzxyy".count('yy', 1))
none of the mentioned
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]]
Heeeo
Heelo
Heleo
White Space
,
e
S
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]]
print('ab cd ef'.title())
Ab cd ef
Ab cd eF
Ab Cd Ef
None of the mentioned
keys, keys
key values, keys
keys, key values
key values, key values
What is the output when we execute
list("hello") ?
['h', 'e', 'l', 'l', 'o']
[' hello']
['llo']
['olleh']
s2.issubset(s1)
s2.issuperset(s1)
s1.issuperset(s2)
s1.isset(s2)
print('abcd'.partition('cd'))
(‘ab’, ‘cd’, ”)
(‘ab’, ‘cd’)
print('a@ 1,'.islower())
Error
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():
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’}
print('1.1'.isnumeric())