Introducing Python © Chirag Wazir 2002 Prev   Index   Next

Data Types

Numbers (integers, float, complex), Strings, Lists, Tuples, Dictionaries

Array

Objects identity, type & value

Everything is an Object!

Mutable & Immutable types

Sequences & Mappings

Indexes & Slices

Data Type Storage Update Access
numbers scalar immutable direct
strings scalar immutable sequence
lists container mutable sequence
tuples container immutable sequence
dictionaries container mutable mapping

a = 'hello world'
a[1]       # 'e'
a[6:]      # 'world'
a[-2:]     # 'ld'
a[:4]      # 'hell'
a[3:5]     # 'lo'

 +---+---+---+---+---+---+
 | P | y | t | h | o | n |
 +---+---+---+---+---+---+
 0   1   2   3   4   5   6
-6  -5  -4  -3  -2  -1