Exercises on Python Tuples

The following exercises cover Tuples in Python.

Exercise 1

Complete the syntax to create a tuple of a string, and two numbers, mytuple.

mytuple = 'apple', 10, 40
Submit Answer
↻ Reset
Show Answer
Fill the fields with missing code.

Exercise 2

Print second element from the tuple mytuple.

mytuple = ('apple', 10, 40)
print(mytuple[])
Submit Answer
↻ Reset
Show Answer
Fill the fields with missing code.

Exercise 3

Print last element in the tuple mytuple using negative index.

mytuple = ('apple', 10, 40)
print(mytuple[])
Submit Answer
↻ Reset
Show Answer
Fill the fields with missing code.

Exercise 4

Iterate over the elements of the tuple mytuple using For loop.

mytuple = ('apple', 10, 40)
for item  :
    print(item)
Submit Answer
↻ Reset
Show Answer
Fill the fields with missing code.