Top 1000+ Solved Problem Solving and Python Programming MCQ Questions Answer
Q. What type of data is: a=[(1,1),(2,4),(3,9)]?
a. array of tuples
b. list of tuples
c. tuples of lists
d. invalid type
Q. Is the following Python code valid?>>> a,b=1,2,3
a. yes, this is an example of tuple unpacking. a=1 and b=2
b. yes, this is an example of tuple unpacking. a=(1,2) and b=3
c. no, too many values to unpack
d. yes, this is an example of tuple unpacking. a=1 and b=(2,3)
Q. Which of the following statements create a dictionary?
a. d = {}
b. d = {“john”:40, “peter”:45}
c. d = {40:”john”, 45:”peter”}
d. all of the mentioned
Q. d = {"john":40, "peter":45}
a. “john”, 40, 45, and “peter”
b. “john” and “peter”
c. 40 and 45
d. d = (40:”john”, 45:”peter”)
Q. Suppose d = {“john”:40, “peter”:45}, to delete the entry for “john” what command do we use?
a. d.delete(“john”:40)
b. d.delete(“john”)
c. del d[“john”]
d. del d(“john”:40)
Q. Suppose d = {“john”:40, “peter”:45}. To obtain the number of entries in dictionary which command do we use?
a. d.size()
b. len(d)
c. size(d)
d. len()
Q. print(list(d.keys()))
a. [“john”, “peter”]
b. [“john”:40, “peter”:45]
c. (“john”, “peter”)
d. (“john”:40, “peter”:45)
Q. Which of these about a dictionary is false?
a. the values of a dictionary can be accessed using keys
b. the keys of a dictionary can be accessed using values
c. dictionaries aren’t ordered
d. dictionaries are mutable