Python-Quizzes | Python Tuples Quiz | Question 9

Question 9: What is the output of the following program?

filter_none

edit
close

play_arrow

link
brightness_4
code

L = [3, 1, 2, 4
T = ('A', 'b', 'c', 'd'
L.sort() 
counter = 0
for x in T: 
    L[counter] += int(x) 
    counter += 1
    break
print(L) 

chevron_right


(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

My Personal Notes arrow_drop_up
Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.