# Arrays Vs Lists
- Arrays need to be declared. Lists don’t
- Arrays can store data very compactly
- Arrays are great for numerical operations
import array
# Array (stores single data type)
array.array('i', [1, 22, 30, 44, 51]) # integer
array.array('d', [2.5, 3.2, 3.3]) # float
array.array('u', ['a', 'b', 'c']) # unicode
#List
ll = ['abc', 10, ['a', 'b', 'c'], (1,2,3)] # List can store anything
import numpy as np
# Numpy Array (it can store various data types)
array_2 = np.array(["numbers", 3, 6, 9, 12])
print (array_2)
print(type(array_2))
No comments:
Post a Comment