On This Page

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

Q1 | ]
  • [4, 5, 6]
  • [3, 6, 9]
  • [1, 4, 7]
  • [1, 2, 3]
Q2 | ] for row in (0, 1, 2)]
  • [7, 8, 9]
  • [4, 5, 6]
  • [2, 5, 8]
  • [1, 4, 7]
Q3 | for col in row] for row in A]
  • [[11, 12, 13], [14, 15, 16], [17, 18, 19]]
  • error
  • [11, 12, 13], [14, 15, 16], [17, 18, 19]
  • [11, 12, 13, 14, 15, 16, 17, 18, 19]
Q4 | -i] for i in range(len(A))]
  • [1, 5, 9]
  • [4, 5, 6]
  • [3, 5, 7]
  • [2, 5, 8]
Q5 | ) for col in range(3)]
  • [3, 6, 9, 16, 20, 24, 35, 40, 45]
  • error
  • [0, 30, 60, 120, 160, 200, 300, 350, 400]
Q6 | , 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
Q7 | , 9], [5, 5, 5])]
  • [1, 2, 3]
  • (1, 2, 3)
  • {1, 2, 3}
  • {}
Q8 | >>>t[1:3]
  • (1, 2)
  • (1, 2, 4)
  • (2, 4)
  • (2, 4, 3)
Q9 | >>>t[1:-1]
  • (1, 2)
  • (1, 2, 4)
  • (2, 4)
  • (2, 4, 3)
Q10 | >>>[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)
Q11 | d["john"]
  • 40
  • 45
  • “john”
  • “peter”
Q12 | >>>t1 < t2
  • true
  • false
  • error
  • none
Q13 | >>>print len(my_tuple)
  • 1
  • 2
  • 5
  • error
Q14 | What is the data type of (1)?
  • tuple
  • integer
  • list
  • both tuple and integer
Q15 | ])
  • now, a=(1,2,4)
  • now, a=(1,3,4)
  • now a=(3,4)
  • error as tuple is immutable
Q16 | )
  • too many arguments for sum() method
  • the method sum() doesn’t exist for tuples
  • 12
  • 9
Q17 | What type of data is: a=[(1,1),(2,4),(3,9)]?
  • array of tuples
  • list of tuples
  • tuples of lists
  • invalid type
Q18 | Is the following Python code valid?>>> a,b=1,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)
Q19 | Tuples can’t be made keys of a dictionary.
  • true
  • false
Q20 | ,)
  • 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
Q21 | Which of the following statements create a dictionary?
  • d = {}
  • d = {“john”:40, “peter”:45}
  • d = {40:”john”, 45:”peter”}
  • all of the mentioned
Q22 | d = {"john":40, "peter":45}
  • “john”, 40, 45, and “peter”
  • “john” and “peter”
  • 40 and 45
  • d = (40:”john”, 45:”peter”)
Q23 | john" in d
  • true
  • false
  • none
  • error
Q24 | d1 == d2
  • true
  • false
  • none
  • error
Q25 | d1 > d2
  • true
  • false
  • error
  • none