CBSE Class 12 Computer Science Question 9 of 42

Solved 2024 Sample Question Paper CBSE Class 12 Computer Science (083) — Question 9

Back to all questions
9
Question

Question 9

Which of the following statement(s) would give an error during execution of the following code ?

tup = (20, 30, 40, 50, 80, 79)
print(tup) #Statement 1
print(tup[3] + 50) #Statement 2
print(max(tup)) #Statement 3
tup[4] = 80 #Statement 4
  1. Statement 1
  2. Statement 2
  3. Statement 3
  4. Statement 4
Answer

Statement 4

Reason — The statement that would give an error during execution of the given code is Statement 4 (tup[4] = 80). This is because tuples in Python are immutable, meaning we cannot modify the elements of a tuple after it has been created. Here, it is attempting to assign 80 to the element at the index 4 of a tuple, which results in an error because tuples do not support item assignment.