Programming Language Python Tuple MCQ Question #3669
Single Choice Not Set

Q Write the output of the following:
a=(23,34,65,20,5)
s=0
for i in a:
    if i%2==0:
        s=s+a[i]
print(s)

ID: #3669 Python Tuple MCQ 248 views
Question Info
#3669Q ID
Not SetDifficulty
Python Tuple MCQTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A 54
  • B 93
  • C 94
  • D error
Correct Answer

Explanation


---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Input In [6], in ()
      3 for i in a:
      4     if i%2==0:
----> 5         s=s+a[i]
      6 print(s)

IndexError: tuple index out of range

Share This Question

Challenge a friend or share with your study group.