d1 1 PDF
d1 1 PDF
a) 10
b) 20
c) 15
d) 0
a) Int
b) Filter
c) List
d) Tuple
a) 105
b) 270
c) 0
d) Error
6) Which of the following modules need to be imported to handle date time computations in
Python?
a) timedate
b) date
c) datetime
d) time
7) What will be the output of the following code snippet?
print(4**3 + (7 + 5)**(1 + 1))
a) 248
b) 169
c) 208
d) 233
10)
The ___ is a built-in function that returns a range object that consists series of integer numbers, which
we can iterate using a for loop.
A. range()
B. set()
C. dictionary{}
D. None of the mentioned above
Question 11
Amongst which of the following is a function which does not have any name?
A. Del function
B. Show function
C. Lambda function
D. None of the mentioned above
Question 12
Question 13
Amongst which of the following is / are the method of convert Python objects for writing data in
a binary file?
A. set() method
B. dump() method
C. load() method
D. None of the mentioned above
14
Amongst which of the following is / are the method used to unpickling data from a binary file?
A. load()
B. set() method
C. dump() method
D. None of the mentioned above
15.
A. Alphabets
B. Numbers
C. Special symbols
D. All of the mentioned above
16
Which Python code could replace the ellipsis (...) below to get the following output? (Select all that
apply.)
captains = {
"Enterprise": "Picard",
"Voyager": "Janeway",
"Defiant": "Sisko",
Enterprise Picard,
Voyager Janeway
Defiant Sisko
print(ship, captain)
print(ship, captains[ship])
d) both a and b
17)
Which of the following lines of code will create an empty dictionary named captains?
a) captains = {dict}
b) type(captains)
c) captains.dict()
d) captains = {}
18) Now you have your empty dictionary named captains. It’s time to add some data!
Specifically, you want to add the key-value pairs "Enterprise": "Picard", "Voyager": "Janeway",
and "Defiant": "Sisko".
Which of the following code snippets will successfully add these key-value pairs to the
existing captains dictionary?
a) captains{"Enterprise" = "Picard"}
captains{"Voyager" = "Janeway"}
captains{"Defiant" = "Sisko"}
b) captains["Enterprise"] = "Picard"
captains["Voyager"] = "Janeway"
captains["Defiant"] = "Sisko"
c) captains = {
"Enterprise": "Picard",
"Voyager": "Janeway",
"Defiant": "Sisko",
captains = {
"Enterprise": "Picard",
"Voyager": "Janeway",
"Defiant": "Sisko",
"Discovery": "unknown",
}Now, say you want to display the ship and captain names contained in the dictionary, but you also
want to provide some additional context. How could you do it?
20 )
You’ve created a dictionary, added data, checked for the existence of keys, and iterated over it with
a for loop. Now you’re ready to delete a key from this dictionary:
captains = {
"Enterprise": "Picard",
"Voyager": "Janeway",
"Defiant": "Sisko",
"Discovery": "unknown",
}
What statement will remove the entry for the key "Discovery"?
a) del captains
b) captains.remove()
c) del captains["Discovery"]
d) captains["Discovery"].pop()