Posamezen element terke v Pythonu
Če želite pridobiti element terke, se morate nanj sklicevati po indeksu:
tpl = ('a', 'b', 'c')
print(tpl[0]) # izpiše 'a'
Podana je terka:
tpl = (1, 2, 3, 4)
Iz nje izpišite prvi element.
Podana je terka:
tpl = ('a', 'b', 3, 4, 'c')
Iz nje izpišite tretji element.
Podana je terka:
tpl = (10, 9, 8, 7, 6)
Iz nje izpišite zadnji element.
Iz terke, podane v prejšnji nalogi, izpišite predzadnji element.
Podana je terka:
tpl = (1, 2, 3)
Poiščite vsoto elementov te terke.