Skip to content
Related Articles

Related Articles

Python-Quizzes | Python Tuples Quiz | Question 9
  • Last Updated : 29 Sep, 2020

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




L = [2e-04, 'a', False, 87
T = (6.22, 'boy', True, 554
for i in range(len(L)): 
    if L[i]: 
        L[i] = L[i] + T[i] 
    else
        T[i] = L[i] + T[i] 
        break

(A) [6.222e-04, ‘aboy’, True, 641]
(B) [6.2202, ‘aboy’, 1, 641]
(C) TypeError
(D) [6.2202, ‘aboy’, False, 87]


Answer: (C)

Explanation: The for loop will run for i = 0 to i = 3, i.e. 4 times(len(L) = 4). 2e-04 is same as 0.0002, thus L[i] = 6.22 + 0.0002 = 6.2202. String addition will result in concatenation, ‘a’ + ‘boy’ = ‘aboy’. False + True is True, it’ll return the integer value of 1. As tuples are immutable, the code will end with TypeError, but elements of L will be updated.

Quiz of this Question
Please comment below if you find anything wrong in the above post

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :