On This Page

This set of Problem Solving and Python Programming Multiple Choice Questions & Answers (MCQs) focuses on Problem Solving And Python Programming Set 32

Q1 | , row2)] for (row1, row2) in zip(A, B)]
  • [0, 30, 60, 120, 160, 200, 300, 350, 400]
  • [[3, 6, 9], [16, 20, 24], [35, 40, 45]]
  • no output
  • error
Q2 | 2 TUPLES (TUPLE ASSIGNMENT, TUPLE AS RETURN VALUE)
  • [1, 2, 3]
  • (1, 2, 3)
  • {1, 2, 3}
  • {}
Q3 | >>>t[1:3]
  • (1, 2)
  • (1, 2, 4)
  • (2, 4)
  • (2, 4, 3)
Q4 | >>>t[1:-1]
  • (1, 2)
  • (1, 2, 4)
  • (2, 4)
  • (2, 4, 3)
Q5 | >>>[t[i] for i in range(0, len(t), 2)]
  • [2, 3, 9]
  • [1, 2, 4, 3, 8, 9]
  • [1, 4, 8]
  • (1, 4, 8)
Q6 | d["john"]
  • 40
  • 45
  • “john”
  • “peter”
Q7 | >>>2 * t
  • (1, 2, 1, 2)
  • [1, 2, 1, 2]
  • (1, 1, 2, 2)
  • [1, 1, 2, 2]
Q8 | >>>t1 < t2
  • true
  • false
  • error
  • none
Q9 | >>>print len(my_tuple)
  • 1
  • 2
  • 5
  • error
Q10 | What is the data type of (1)?
  • tuple
  • integer
  • list
  • both tuple and integer
Q11 | ])
  • now, a=(1,2,4)
  • now, a=(1,3,4)
  • now a=(3,4)
  • error as tuple is immutable
Q12 | )
  • too many arguments for sum() method
  • the method sum() doesn’t exist for tuples
  • 12
  • 9
Q13 | What type of data is: a=[(1,1),(2,4),(3,9)]?
  • array of tuples
  • list of tuples
  • tuples of lists
  • invalid type
Q14 | ,2,3
  • yes, this is an example of tuple unpacking. a=1 and b=2
  • yes, this is an example of tuple unpacking. a=(1,2) and b=3
  • no, too many values to unpack
  • yes, this is an example of tuple unpacking. a=1 and b=(2,3)
Q15 | Tuples can’t be made keys of a dictionary.
  • true
  • false
Q16 | ,)
  • yes, a=(1,2,3,4) and b=(1,2,3,4)
  • yes, a=(1,2,3) and b=(1,2,3,4)
  • no because tuples are immutable
  • no because wrong syntax for update() method
Q17 | Which of the following statements create a dictionary?
  • d = {}
  • d = {“john”:40, “peter”:45}
  • d = {40:”john”, 45:”peter”}
  • all of the mentioned
Q18 | d = {"john":40, "peter":45}
  • “john”, 40, 45, and “peter”
  • “john” and “peter”
  • 40 and 45
  • d = (40:”john”, 45:”peter”)
Q19 | john" in d
  • true
  • false
  • none
  • error
Q20 | d1 == d2
  • true
  • false
  • none
  • error
Q21 | d1 > d2
  • true
  • false
  • error
  • none
Q22 | Suppose d = {“john”:40, “peter”:45}, to delete the entry for “john” what command do we use?
  • d.delete(“john”:40)
  • d.delete(“john”)
  • del d[“john”]
  • del d(“john”:40)
Q23 | Suppose d = {“john”:40, “peter”:45}. To obtain the number of entries in dictionary which command do we use?
  • d.size()
  • len(d)
  • size(d)
  • d.len()
Q24 | print(list(d.keys()))
  • [“john”, “peter”]
  • [“john”:40, “peter”:45]
  • (“john”, “peter”)
  • (“john”:40, “peter”:45)
Q25 | Which of these about a dictionary is false?
  • the values of a dictionary can be accessed using keys
  • the keys of a dictionary can be accessed using values
  • dictionaries aren’t ordered
  • dictionaries are mutable