-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExampleNumpy.py
48 lines (40 loc) · 965 Bytes
/
ExampleNumpy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import numpy as np
print('Hello world')
# Creating Array
a = np.array([1, 2, 3])
b = np.array([(1, 2, 3), (4, 5, 6)], dtype=int)
# print(b)
# initial Placeholders
# 1D array of alll zerros
c = np.zeros(3)
# 2D array of all zerros
d = np.zeros((2, 3))
# 3x4 array of random floats betweeen 0-1
f = np.random.rand(3, 5)
# 4x4 array of 0 with 1 on digonal
e= np.eye(4)
# print(e)
# saving and loading
# np.save("newarray",x)
# Operator
# copy array a in array z (Replica)
z = np.copy(a)
v = a.sort()
m = np.append(z, 9)
# n = np.insert(z, 9,2)
# print (n)
# Array Mathematics
# adding two matrix value
ba = [[-2, 2, 3], [ 5, -2, 3], [ 9, 2, -2]]
ab = [ [ 1, 2, -1], [ 4, -1, 3], [-1, 2, -2]]
aba = np.add(ba,ab)
print(aba)
# Multily values of 2 array
bb = np.multiply(z,a)
# Generating array of 10 to 20
# value total 5
arry = np.random.randint(10,20,5)
# print (arry)
# Convert string to int
# str = '100'
# print('Covert string to int: ', int(str))