Python-Quizzes | Python List Quiz | Question 13
Question 13: Find the output of the following program:
d1 = [ 10 , 20 , 30 , 40 , 50 ] d2 = [ 1 , 2 , 3 , 4 , 5 ] print ( d1 - d1 ) |
(A) [10, 20, 30, 40, 50]
(B) [1, 2, 3, 4, 5]
(C) [10, 20, 30, 40, 50,-1, -2, -3, -4, -5]
(D) No Output
Answer: (D)
Explanation: Unlike addition or relational operators, not all the arithmetic operators can use lists as their operands. Since the – minus operator can’t take lists as its operand no output will be produced. The program will produce the following error:
unsupported operand type(s) for -: 'list' and 'list'