Table of Contents

7. Arrays


In [ ]:
import array as arr
a = arr.array('d', [1.1, 3.5, 4.5])
print(a)

Element access


In [ ]:
a[1]

In [ ]:
a[1] = 4.0
a

Slice access


In [ ]:
a[1:2]

Appending elements


In [ ]:
a.append(5.0)
a

Concatenating arrays


In [ ]:
a.extend([5.0, 6.0, 7.0])
a

In [ ]:
a += arr.array('d', [1.1, 4.0, 4.5])
a

Deleting elements


In [ ]:
# By value
a.remove(4.0)
a

In [ ]:
# By index
a.pop(3)
a