Professional Documents
Culture Documents
Chapter-3 MCQs
Chapter-3 MCQs
tuple1=(5,1,7,6,2)
35 (5,1,6,2) (5,1,7,6) (5,1,7,6,2) Error D
tuple1.pop(2)
print(tuple1)
print(len(tupl1))
Which one of the following is correct syntax to
38 t=(10) t={10} t=10 t=(10,) D
create tuple with one element?
Which of the following is not the correct
39 s={} s=set({}) s=set((1,2,3,4)) B
syntax for creating a set? s={1,2,3,4}
What will be the output of the following Python
code?
40 7 4 8 error B
nums = set([1,1,2,3,3,3,4,4])
print(len(nums))
Which of the following statements is used to
41 {} set( ) [] () B
create an empty set?
If a={5,6,7,8}, which of the following
42 print(len(a)) print(min(a)) a.remove(5) a[2]=45 D
statements is false?
Error as there is no add Error as 5 already exists
43 If a={5,6,7}, what happens when a.add(5) is a={5,5,6,7} a={5,6,7} B
function for set data type in the set
executed?
Is the following Python code valid?
Error, elements of a Error, subsets aren’t
44 Yes, 7 is printed Yes, {7,5} is printed C
a={3,4,{7,5}} set can’t be printed allowed
print(a[2][0])
To add one element in set _____ method is
45 add() append() extend() insert() A
used.
To add more than one item in set _____
46 add() update() extend() insert() B
method is used.
The isdisjoint() method returns True if none of
47 the items are present in both sets, otherwise, TRUE FALSE A
it returns False.
What is the output of the following code
{‘PYnative’, 1, (‘abc’, {‘PYnative’, 1, (‘abc’,
48 Error B
aSet = {1, 'PYnative', ('abc', 'xyz'), True} ‘xyz’), True} ‘xyz’)}
print(aSet)
What is the output of the following
set1 = {10, 20, 30, 40} {40, ’10’, 50, 20, 60, {40, 10, ’10’, 50, 20, 60,
53 {40, 10, 50, 20, 60, 30} ERROR C
set2 = {50, 20, "10", 60} 30} 30}
set3 = set1.union(set2)
print(set3)
What is the output of the following set
operation.
set1.difference_update(set2)
print(set1)
55 The union() method returns a new set with all TRUE FALSE A
items from both sets by removing duplicates
What is the output of the following
{‘Blue’, ‘Orange’,
sampleSet = {"Yellow", "Orange", "Black"} {‘Blue’, ‘Orange’,
56 ‘Yellow’, ‘Orange’, ERROR B
sampleSet.add("Blue") ‘Yellow’, ‘Black’}
‘Black’}
sampleSet.add("Orange")
print(sampleSet)
What is the output of the following set
operation
set3 = set2.difference(set1)
print(set3)
What is the output of the following code
58 Yellow Orange ERROR C
sampleSet = {"Yellow", "Orange", "Black"}
print(sampleSet[1])
Which of the following statements create a d = {“john”:40, d = {40:”john”,
59 All D
dictionary? d = {} “peter”:45} 45:”peter”}
Suppose d = {“john”:40, “peter”:45}, to delete
60 the entry for “john” what command do we d.delete(“john”:40) d.delete(“john”) del d[“john”] del d(“john”:40) C
use?
Suppose d = {“john”:40, “peter”:45}. To obtain
61 the number of entries in dictionary which d.size() len(d) size(d) d.len() B
command do we use?
What will be the output of the following Python
code ?
62 [“john”, “peter”] [“john”:40, “peter”:45] (“john”, “peter”) (“john”:40, “peter”:45) A
d = {"john":40, "peter":45}
print(list(d.keys()))
The keys of a
The values of a
dictionary can be Dictionaries aren’t
63 dictionary can be Dictionaries are mutable B
accessed using ordered
accessed using keys
Which of these about a dictionary is false? values
What will be the output of the following Python
code snippet?
64 1A2B3C 12 3 ABC 1:”A” 2:”B” 3:”C” A
a={1:"A",2:"B",3:"C"}
for i,j in a.items():
print(i,j,end=" ")
What will be the output of the following Python
code snippet?
65 1 A 4 ERROR B
a={1:"A",2:"B",3:"C"}
print(a.get(1,4))
What will be the output of above Python
code?
66 abc 5 {"abc":5} ERROR D
d1={"abc":5,"def":6,"ghi":7}
print(d1[0])