Quiz on Python Collections
FREE Online Courses: Dive into Knowledge for Free. Learn More!
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 15 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Categories
- Not categorized 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
-
Question 1 of 15
1. Question
- Which of the following is not a data structure that is in the form of a dictionary?
CorrectIncorrect -
Question 2 of 15
2. Question
- Find the correct way to import the required module to use the ChainMap.
CorrectIncorrect -
Question 3 of 15
3. Question
- Which of the following built-in data structures are not given the option to modify their properties?
CorrectIncorrect -
Question 4 of 15
4. Question
- Find the value in the below options that cannot be given as an input to the Counter() function.
CorrectIncorrect -
Question 5 of 15
5. Question
- Which of the following is the property of an OrderedDict over a Dictionary?
CorrectIncorrect -
Question 6 of 15
6. Question
What is the output of the below code?
dDic=defaultdict(lambda:0)
dDic[3]:4
dDic[5]:1
dDic[4]CorrectIncorrect -
Question 7 of 15
7. Question
- ds=ChainMap({1:’s’,2:’3′,4:’t’},{‘t’:4,4:5,’y’:3})
CorrectIncorrect -
Question 8 of 15
8. Question
Which of the following is the correct way to create a NamedTuple
a.
nTup=namedtuple(‘std’,[‘name’,’id’,’section’])
user=nTup(‘abc’,’1234′,’A’)
b.
nTup=namedtuple(‘std’,[‘name’,’id’,’section’])
user=nTup([‘abc’,’1234′,’A’])
c.
nTup=namedtuple(‘std’,[‘name’,’id’,’section’])
user=nTup(‘name’:abc’,’id’:’1234′,’section’:’A’)
CorrectIncorrect -
Question 9 of 15
9. Question
What is the output of the below code?
from collections import OrderedDict
oDict[2]=4
oDict[3]=9
oDict[1]=1
print(oDict.popitem())CorrectIncorrect -
Question 10 of 15
10. Question
Which of the following is the right way to add the item at the starting to the following Queue?
dQue=deque([‘a’,’b’,’c’])
CorrectIncorrect -
Question 11 of 15
11. Question
What is the output of the below code?
oDict=OrderedDict()
oDict[1]=’a’
oDict[2]=’b’
oDict[3]=’c’
oDict[4]=’d’
oDict.pop(3)
oDict[3]=’e’
for i in oDict:
print(i,”:”,oDict[i])
CorrectIncorrect -
Question 12 of 15
12. Question
Which of the following codes allows us to create a list from which does not allow removing the elements and does not give an error on trying to delete?
a.
class UList(UserList):
def clear(self,s=None):
raise RuntimeError(“Deletion not allowed”)
def pop(self,s=None):
raise RuntimeError(“Deletion not allowed”)
def remove(self,s=None):
raise RuntimeError(“Deletion not allowed”)
b.
from collections import UserList
class UList(UserList):
def clear(self,s=None):
raise Error(“Deletion not allowed”)
def pop(self,s=None):
raise Error(“Deletion not allowed”)
def remove(self,s=None):
raise Error(“Deletion not allowed”)
c.
from collections import UserList
class UList(UserList):
def clear(self,s=None):
print(“Deletion not allowed”)
def pop(self,s=None):
print(“Deletion not allowed”)
def remove(self,s=None):
print(“Deletion not allowed”)
CorrectIncorrect -
Question 13 of 15
13. Question
- Which of the following functions can be used to override the string property of adding the characters?
CorrectIncorrect -
Question 14 of 15
14. Question
What is the output of the following code?
c=Counter([1,2,3,4,1,2,5,6])
c.most_common(1)CorrectIncorrect -
Question 15 of 15
15. Question
What is the output of the following code?
class UDict(UserDict):
def pop(self, ele=None):
raise TypeError(“Not Allowed”)
def _del_(self):
raise TypeError(“Not Allowed”)
def popitem(seld, ele=None):
raise TypeError(“Not Allowed”)uDic=UDict({1:1,4:2,16:4})
uDic[25]=5
uDicCorrectIncorrect