|
17 | 17 | a = np.array([(1, 2, 3), (4, 5, 6)]) |
18 | 18 |
|
19 | 19 | #----9 |
20 | | -#Finding sum of the elemnts by columns |
21 | | -#axis = 0 means column |
22 | | -colsum = a.sum(axis = 0) |
| 20 | +# Finding sum of the elemnts by columns |
| 21 | +# axis = 0 means column |
| 22 | +colsum = a.sum(axis=0) |
23 | 23 | print("\nThe sum of all the value in the array by columns are {}".format(colsum)) |
24 | | -#Finding sum of the elemnts by rows |
25 | | -#axis = 1 means rows |
26 | | -rowsum = a.sum(axis = 1) |
| 24 | +# Finding sum of the elemnts by rows |
| 25 | +# axis = 1 means rows |
| 26 | +rowsum = a.sum(axis=1) |
27 | 27 | print("\nThe sum of all the value in the array by rows are {}".format(rowsum)) |
28 | 28 | """----------------------------------------------------------------------------------------------------------------------------------------------------------""" |
29 | 29 |
|
30 | 30 | #----10 |
31 | | -#Finding sqaure root of each element in the array |
| 31 | +# Finding sqaure root of each element in the array |
32 | 32 | sqrt = np.sqrt(a) |
33 | 33 | print("\nThe sqaure root of each elements are \n{}".format(sqrt)) |
34 | 34 | """----------------------------------------------------------------------------------------------------------------------------------------------------------""" |
35 | 35 |
|
36 | 36 | #----11 |
37 | | -#Finding standard deviation of the array |
| 37 | +# Finding standard deviation of the array |
38 | 38 | stnd = np.std(a) |
39 | 39 | print("\nThe standard deviation of array is \n{}".format(stnd)) |
40 | 40 | """----------------------------------------------------------------------------------------------------------------------------------------------------------""" |
41 | 41 |
|
42 | | -#lets set another numpy array for performing arithmetic calculations |
| 42 | +# lets set another numpy array for performing arithmetic calculations |
43 | 43 | b = np.array([(10, 11, 12), (13, 14, 15)]) |
44 | 44 | print("\nAnother numpy array given for calculations \n{}".format(b)) |
45 | 45 | """----------------------------------------------------------------------------------------------------------------------------------------------------------""" |
46 | 46 |
|
47 | 47 | #-----12 |
48 | | -#Finding the sum of two arrays |
| 48 | +# Finding the sum of two arrays |
49 | 49 | asumb = a + b |
50 | 50 | print("\nThe sum of two arrays are \n{}".format(asumb)) |
51 | | -#Finding the substraction of two arrays |
| 51 | +# Finding the substraction of two arrays |
52 | 52 | aminusb = a - b |
53 | 53 | print("\nThe substraction of two arrays are \n{}".format(aminusb)) |
54 | | -#Finding the multiplication of two arrays |
| 54 | +# Finding the multiplication of two arrays |
55 | 55 | amultib = a * b |
56 | 56 | print("\nThe multiplication of two arrays are \n{}".format(amultib)) |
57 | | -#Finding the division of two arrays |
| 57 | +# Finding the division of two arrays |
58 | 58 | adivb = a / b |
59 | 59 | print("\nThe division of two arrays are \n{}".format(adivb)) |
60 | 60 | """----------------------------------------------------------------------------------------------------------------------------------------------------------""" |
61 | 61 |
|
62 | 62 | #---13 |
63 | | -#Concatinating numpy's vertically |
| 63 | +# Concatinating numpy's vertically |
64 | 64 | vstack = np.vstack((a, b)) |
65 | 65 | print("\nVertically stacked numpy's \n{}".format(vstack)) |
66 | | -#Concatinating numpy's horizontally |
| 66 | +# Concatinating numpy's horizontally |
67 | 67 | hstack = np.hstack((a, b)) |
68 | 68 | print("\nHorizontally stacked numpy's \n{}".format(hstack)) |
69 | 69 | """----------------------------------------------------------------------------------------------------------------------------------------------------------""" |
70 | 70 |
|
71 | 71 | #----14 |
72 | | -#Combining columns of a numpy into a single column |
| 72 | +# Combining columns of a numpy into a single column |
73 | 73 | single_a = a.ravel() |
74 | 74 | print("\nThe first numpy array now have a single column\n{}".format(single_a)) |
75 | 75 | """----------------------------------------------------------------------------------------------------------------------------------------------------------""" |
76 | 76 |
|
77 | 77 | #----15 |
78 | | -#Exponential function |
| 78 | +# Exponential function |
79 | 79 | ex_a = np.exp(a) |
80 | 80 | print("\nThe elements of the first numpy array raised to the e power =\n{}".format(ex_a)) |
81 | | -#logarithmic function |
82 | | -#natural logarithmic (ln) |
| 81 | +# logarithmic function |
| 82 | +# natural logarithmic (ln) |
83 | 83 | log_a = np.log(a) |
84 | 84 | print("\nThe natural log of the elements of the first numpy array =\n{}".format(log_a)) |
85 | | -#logarithmic (ln) with base 10 or log |
| 85 | +# logarithmic (ln) with base 10 or log |
86 | 86 | log_a = np.log10(a) |
87 | 87 | print("\nThe log with base 10 of the elements of the first numpy array =\n{}".format(log_a)) |
88 | 88 | """----------------------------------------------------------------------------------------------------------------------------------------------------------""" |
89 | 89 |
|
90 | 90 | #---16 |
91 | | -#the first value passed in the argument will be the value to start with |
92 | | -#second will be the value to end at |
93 | | -#third will be how many numbers do you want in between first and second arguments |
| 91 | +# the first value passed in the argument will be the value to start with |
| 92 | +# second will be the value to end at |
| 93 | +# third will be how many numbers do you want in between first and second arguments |
94 | 94 | al = np.linspace(1, 5, 10) |
95 | 95 | print("\nThese are 10 numbers in between 1 and 5 \n{}".format(al)) |
96 | 96 | """----------------------------------------------------------------------------------------------------------------------------------------------------------""" |
97 | 97 |
|
98 | 98 |
|
99 | | -#That's it! |
| 99 | +# That's it! |
100 | 100 | print("\nThe End!") |
0 commit comments