-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathniethlab.py
95 lines (66 loc) · 1.71 KB
/
niethlab.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import numpy as np
#to get the dimantion of a given array
a=np.array(65)
b=np.array([1,2,3,4])
c=np.array([[1,2,3],[4,5,6]])
d=np.array([[[1,2,3],[4,5,6]],[[1,2,3],[4,5,6]]])
e=np.array([[[1,2,3],[4,5,6],[7,8,9]]
,[[1,2,3],[4,5,6],[7,8,9]],
[[1,2,3],[4,5,6],[7,8,9]]])
print(a.ndim)
print(b.ndim)
print(c.ndim)
print(d.ndim)
print(e.ndim)
#to get the data type of a array it depands on which data type
# of higest value is prensent in the array it will give the size of the
# higest data tye to all the element of array
#i.e. sum of all the data type size of elements
c=np.array([[1,2,3],[4,5,6]])
print(c.itemsize)
print(c.dtype)
c=np.array([[1,2.542424,3],[4,5.5424232,6]])
print(c.itemsize)
print(c.dtype)
c=np.array([[1,2,+23-3j],[4,5,6+6j]])
print(c.itemsize)
print(c.dtype)
c=np.array([[1,'2','3'],['4','5',6]])
print(c.itemsize)
print(c.dtype)
c=np.array([["AR","YA","N"],["4",5,6]])
print(c.itemsize)
print(c.dtype)
random=np.random.rand(4,8)
print(random)
#to get the mean of a row
c=np.array([[1,2,3],[4,5,6]])
print(np.mean(c,axis=0))
print(np.mean(c,axis=1))
c=np.array([[1,2,3],[4,5,6]])
d=np.array([[4,5,6],[1,2,3]])
e=np.append(c,d)
print(e)
c=np.array([[1,2],[3,4],[5,6]])
# print(np.insert(a,2,[4,5],axis=0))
# print("\n")
# print(np.insert(a,2,[5,4],axis=1))
# print("\n")
x=np.array([[1,2],[3,4]],dtype=np.float64)
y=np.array([[5,6],[7,8]],dtype=np.float64)
print(x+y)
print(np.add(x,y))
print("\n")
print(x-y)
print(np.subtract(x,y))
print(x*y)
print(np.multiply(x,y))
print(x/y)
print(np.divide(x,y))
print(np.multiply(x,y))
print(np.dot(x,y))
print(np.cross(x,y))
x=np.array([[1,2,3]],dtype=np.float64)
y=np.array([[[4],[5],[6]]],dtype=np.float64)
sum=x+y
print(sum)