Python-Quizzes | Python Tuples Quiz | Question 9
Question 9: What is the output of the following program?
L = [3, 1, 2, 4] T = ('A', 'b', 'c', 'd') L.sort() counter = 0for x in T: L[counter] += int(x) counter += 1 breakprint(L) |
(A) [66, 97, 99, 101]
(B) [66, 68, 70, 72]
(C) [66, 67, 68, 69]
(D) ValueError
Answer: (D)
Explanation: After sort(L), L will be = [1, 2, 3, 4]. Counter = 0, L[0] i.e. 1, x = ‘A’, but Type Conversion of char ‘A’ to integer will throw error and the value cannot be stored in L[0], thus a ValueError.
Quiz of this Question
Please comment below if you find anything wrong in the above post




