Skip to content

Variables And Collections

A name is bound by assignment. An annotation such as year: num is a contract checked when the value is assigned.

Lists, tuples, and dictionaries use familiar literals and indexing. Collection methods return new values rather than changing the original.

name = "Nilakantha"
year: num = 1444
print(name, year)
scores = [90, 72, 85]
print(len(scores), scores[0])
point = (3, 4)
print(point)
ages = {"ada": 36}
print(ages["ada"])
Run in playground
Output
"Nilakantha" 1444
3 90
(3, 4)
36