Skip to content

Commit 6d0b19e

Browse files
authored
Update NumPy.py
1 parent 5872a03 commit 6d0b19e

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

Diff for: NumPy.py

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import numpy as np
22
import time
33
import sys
4+
import matplotlib.pyplot as plt
45

56

67
a = np.array([1,2,3])
@@ -11,11 +12,13 @@
1112

1213
S = range(1000)
1314
print(S)
14-
print(sys.getsizeof(5)*len(S)) # List - size of one element multiplied by the number of all elements, so we got the size of all elements
15+
print(sys.getsizeof(5)*len(S)) # List - size of one element multiplied by the number of all elements,
16+
# so we got the size of all elements
1517
print(sys.getsizeof(5)) #size of one element
1618

1719
D = np.arange(1000)
18-
print(D.size * D.itemsize) # NumPy - size of one element multiplied by the number of all elements, so we got the size of all elements
20+
print(D.size * D.itemsize) # NumPy - size of one element multiplied by the number of all elements,
21+
# so we got the size of all elements
1922

2023
SIZE = 1000000
2124
L1 = range(SIZE)
@@ -61,7 +64,7 @@
6164
print("\n", np.sqrt(a)) #square
6265
print("\n", np.std(a)) #Standart Deviation (средне квадратическое отклонение)
6366

64-
b = np.array([(7,5,10),(25,34,2),(0,1,3)])
67+
b = np.array([(7,5,10),(25,34,2),(7,1,3)])
6568

6669
print("\n", a+b) #sum of matrices
6770
print("\n", a-b) #substraction of matrices
@@ -71,3 +74,15 @@
7174
print("\n"*2,np.vstack((a,b))) #concatenation along the first axis ->
7275
print("\n"*2,np.hstack((a,b))) #stack arrays in sequence horizontaly (column wise)
7376
print("\n", a.ravel()) #into a single column
77+
78+
x = np.arange(0, 3 * np.pi, 0.1 )
79+
y = np.sin(x)
80+
z = np.cos(x)
81+
plt.plot(x,y) #sin plot
82+
plt.plot(x,z) #cos plot
83+
plt.show()
84+
85+
ar = np.array([2, 5, 10])
86+
print("\n", np.exp(ar)) #exponential
87+
print("\n", np.log(ar)) #natural log с основой 2
88+
print(np.log10(ar)) #с основой 10

0 commit comments

Comments
 (0)