8000 Some functions in Numpy · avinashn/programminginpython.com@856f82a · GitHub
[go: up one dir, main page]

Skip to content

Commit 856f82a

Browse files
committed
Some functions in Numpy
1 parent 37d750d commit 856f82a

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

numpy_functions.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import numpy as np
2+
3+
# Create an array of integers from 0 to 9
4+
arr = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
5+
6+
# Create a range of values from 0 to 9 with a step of 2
7+
range_arr = np.arange(0, 10, 2)
8+
print('The range of values from 0 to 9 with a step of 2: \t', range_arr)
9+
10+
# Create an array of zeros with 3 rows and 4 columns
11+
zeros_arr = np.zeros((3, 4))
12+
print('An array of zeros with 3 rows and 4 columns: \t', zeros_arr)
13+
14+
# Create an array of ones with 2 rows and 3 columns
15+
ones_arr = np.ones((2, 3))
16+
print('An array of ones with 2 rows and 3 columns: \t', ones_arr)
17+
18+
# Create an array with 5 evenly spaced values between 0 and 1
19+
linspace_arr = np.linspace(0, 1, 5)
20+
print('An array with 5 evenly spaced values between 0 and 1: \t', linspace_arr)
21+
22+
# Create an array of 5 random values between 0 and 1
23+
rand_arr = np.random.rand(5)
24+
print('An array of 5 random values between 0 and 1: \t', rand_arr)
25+
26+
# Find the maximum value in the array
27+
max_val = np.max(arr)
28+
print('Maximum value in the array: \t', max_val)
29+
30+
# Find the minimum value in the array
31+
min_val = np.min(arr)
32+
print('Minimum value in the array: \t', min_val)
33+
34+
# Find the mean value of the array
35+
mean_val = np.mean(arr)
36+
print('Mean value of the array: \t', mean_val)
37+
38+
# Find the standard deviation of the array
39+
std_val = np.std(arr)
40+
print('Standard deviation of the array: \t', std_val)

0 commit comments

Comments
 (0)
0