Basic Python Datatypes

These are the three core data types in python. Of course there are strings, int too. I'm listing this here as I often forget these:

List

Somewhat similar to tuple (see below) but changeable. Uses square brackets instead of parenthesis in tuple.

1>>> kirk = ["James Kirk", 34, "Captain", 2265]
2>>> type(kirk)
3<class 'list'>

Tuple

A tuple is a collection which is ordered and unchangeable.

1>>> mytuple = ("apple", "banana", "cherry")
2>>> type(mytuple)
3<class 'tuple'>

Dictionary

1>>> comedian = {'name': 'Eric Idle', 'age': 74}
2>>> type(comedian)
3<class 'dict'>
4>>>