⊗pyPmTpEl 66 of 208 menu

Individual element of a tuple in Python

To get an element of a tuple, you need to access it by index:

tpl = ('a', 'b', 'c') print(tpl[0]) # 'a'

A tuple is given:

tpl = (1, 2, 3, 4)

Extract the first element from it.

A tuple is given:

tpl = ('a', 'b', 3, 4, 'c')

Derive the third element from it.

A tuple is given:

tpl = (10, 9, 8, 7, 6)

Extract the last element from it.

From the tuple given in the previous problem, output the penultimate element.

A tuple is given:

tpl = (1, 2, 3)

Find the sum of the elements of this tuple.

byenru