import numpy as np
arr = np.array([1, 2, 3, 4, 5])
print(arr)
print(type(arr))
print(np.__version__)

# tuple

arr = np.array((6, 7, 8, 9, 10))
print('from tuple:', arr)

# multi dimension arrays
arr = np.array([[1, 2, 3], [4, 5, 6]])
print('two Dim')
print(arr,'\n')

print('three Dim')
arr = np.array([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]])
print(arr)

# Check number of dimensions

a = np.array(42)
b = np.array([1, 2, 3, 4, 5])
c = np.array([[1, 2, 3], [4, 5, 6]])
d = np.array([[[1, 2, 3], [4, 5, 6]], [[1, 2, 3], [4, 5, 6]]])

print('\n dimensions \n')
print(a.ndim)
print(b.ndim)
print(c.ndim)
print(d.ndim)

# Create a 5-D array

arr = np.array([1, 2, 3, 4], ndmin=5)
print(arr)
print('number of dimensions :', arr.ndim)

# What will be printed ?
arr = np.array([1, 2, 3, 4, 5, 6, 7])
print(arr[:2])

arr = np.array([10, 15, 20, 25, 30, 35, 40])
print(arr[::2])

# slicing 2-D array

arr = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])
print(arr[1, 1:4])

arr = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10],[10,11,12,13,14]])
print(arr[0:3, 2]) # first dim is the entire array. The second is element 2
                   # of every 'row'

# From both elements, slice index 1 to index 4 (not included), this will return a 2-D array:
arr = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])
print(arr[0:2, 1:4])

# Arrange - takes from element one up to element two (excl) with jumps of three
t = np.arange(0.0, 3.0, 0.2)
print(t)

# Instead of a loop , using numpy array
x = np.array([1,2,3])
y = []
y = x**2   # replace for x1 in x: y.append(x1**2)
print(y)


