0% found this document useful (0 votes)
12 views4 pages

3 Shyamendra Module3 DHA1

Management can be considered both a science and an art, each aspect contributing to its effectiveness and complexity. ### Management as a Science: 1. **Systematic Body of Knowledge**: Management involves a structured set of theories, principles, and frameworks that guide decision-making. 2. **Use of Scientific Methods**: Managers often rely on data analysis, statistical methods, and empirical research to inform their strategies and decisions. 3. **Predictability**: Certain management practices

Uploaded by

shikshaaaa885
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

3 Shyamendra Module3 DHA1

Management can be considered both a science and an art, each aspect contributing to its effectiveness and complexity. ### Management as a Science: 1. **Systematic Body of Knowledge**: Management involves a structured set of theories, principles, and frameworks that guide decision-making. 2. **Use of Scientific Methods**: Managers often rely on data analysis, statistical methods, and empirical research to inform their strategies and decisions. 3. **Predictability**: Certain management practices

Uploaded by

shikshaaaa885
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Module 3 DHA 1

Shyamendra Singh, 2201614, B.Tech (AE) ----------- S.No. 3

Question: Write ten functions of NumPy with Examples

These are ten functions of NumPy:

1. add
2. subtract
3. divide
4. multiply
5. sqrt
6. sum
7. mean
8. min
9. max
10. argmax

****Importing NumPy

In [2]:

#Importing NumPy

import numpy as np

1. add

add() is used to add (elementwise) given arrays or matrices.

In [3]:

a=np.array([6,7,9,10])
b=np.array([5,9,7,6])

print(np.add(a,b))

[11 16 16 16]
2. subtract

np.subtract(x1,x2) is used to subtract (elementwise) to arrays or matrices.

In [7]:

a=np.array([[9,15,13],
[14,11,9]])
b=np.array([[2,9,5],
[5,6,3]])

print(np.subtract(a,b))

[[7 6 8]
[9 5 6]]

3. divide

np.divide(x1, x2) divide arguments element-wise

In [3]:

a=np.array([[9,15,14],
[14,18,16]])
b=np.array([[3,5,2],
[7,6,4]])

print(np.divide(a,b))

[[3. 3. 7.]
[2. 3. 4.]]

4. multiply

np.multiply(x1, x2) multiply arguments element-wise

In [4]:

a=np.array([[[9,15,13],
[14,11,9],
[1,2,4]]])
b=np.array([[[2,9,5],
[5,6,3],
[2,3,1]]])

print(np.multiply(a,b))

[[[ 18 135 65]


[ 70 66 27]
[ 2 6 4]]]
5. sqrt

np.sqrt(array,axis) return the square root of the array elements over the given axis.

In [5]:

a=np.array([[9,16,4],
[36,9,49]])

print(np.sqrt(a))

[[3. 4. 2.]
[6. 3. 7.]]

6. sum

np.sum(array,axis) return the sum of the array elements over the given axis.

In [8]:

a=np.array([[9,15,13],
[14,11,9]])

s= np.sum(a)
print("Sum of all the elements in array 'a' is",s)

Sum of all the elements in array 'a' is 71

7. mean

np.mean(array, axis) returns the average of the array elements along given axis.

In [4]:

b=np.array([[2,9,5],
[5,6,3]])

print("Mean of array 'b' is", np.mean(b))

Mean of array 'b' is 5.0

8. min

np.min(array, axis) return the minimum value along a given axis.


In [33]:

a=np.array([[51,15,17],
[19,11,9]])

print("Min from whole matrix=", a.min())


print()
print("Min along axis 1=", a.min(axis=1))

Min from whole matrix= 9

Min along axis 1= [15 9]

9. max

np.max(array, axis) return the maximum value a given axis.

In [42]:

a=np.array([[100,15,17],
[11,11,999]])

print("Max from whole matrix=", a.max())


print()
print("Max along axis 1=", a.max(axis=1))

Max from whole matrix= 999

Max along axis 1= [100 999]

10.argmax

argmax() returns indices of the maximum values along the given axis

In [3]:

a=np.array([[100,15,17],
[11,11,999]])

print("Index of max in whole matrix=", a.argmax())


print()
print("Index of max along axis 1=", a.argmax(axis=1))

Index of max in whole matrix= 5

Index of max along axis 1= [0 2]

You might also like