Single Choice Not Set

QWhat is the output of the following code
aTuple = (100, 200, 300, 400, 500)
print(aTuple[-2])
print(aTuple[-4:-1])

ID: #3713 Python Tuple MCQ 426 views
Question Info
#3713Q ID
Not SetDifficulty
Python Tuple MCQTopic

Choose the Best Option

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

  • A IndexError: tuple index out of range
  • B 400 (200, 300, 400)
Correct Answer

Explanation

400
(200, 300, 400)

Use the range of negative indexes to start a search from the end of the tuple.

Share This Question

Challenge a friend or share with your study group.