Individual element of a tuple in Python
To get an element of a tuple, you need to access it by index:
pythontpl = ('a', 'b', 'c')
print(tpl[0]) # 'a'
Задание 1
A tuple is given:
pythontpl = (1, 2, 3, 4)
Extract the first element from it.
Задание 2
A tuple is given:
pythontpl = ('a', 'b', 3, 4, 'c')
Derive the third element from it.
Задание 3
A tuple is given:
pythontpl = (10, 9, 8, 7, 6)
Extract the last element from it.
Задание 4
From the tuple given in the previous problem, output the penultimate element.
Задание 5
A tuple is given:
pythontpl = (1, 2, 3)
Find the sum of the elements of this tuple.