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

QWhat is the output of the following
aTuple = (10, 20, 30, 40, 50, 60, 70, 80)
print(aTuple[2:5], aTuple[:4], aTuple[3:])

ID: #3712 Python Tuple MCQ 212 views
Question Info
#3712Q ID
Not SetDifficulty
Python Tuple MCQTopic

Choose the Best Option

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

  • A (30, 40, 50) (10, 20, 30, 40) (40, 50, 60, 70, 80)
  • B (20, 30, 40, 50) (10, 20, 30, 40) (30, 40, 50, 60, 70, 80)
Correct Answer

Explanation

(30, 40, 50) (10, 20, 30, 40) (40, 50, 60, 70, 80)

To get a sub tuple out of the tuple, we need to specify the range of indexes.  We need to specify where to start and where to end the range.

Syntaxtuple[start:end] If the start is missing it takes 0 as the starting index.

Share This Question

Challenge a friend or share with your study group.