**Registrations Closing Soon** for **DevOps Certification Training** by CloudxLab | Registrations Closing in

- Home
- Assessment

Let us create the below function (`multiply_loops`

) which takes two arrays as input and computes their **multiplication using normal Python way**.

```
def multiply_loops(A, B):
c=np.zeros((A.shape[0], B.shape[1]))
for i in range(A.shape[0]):
for k in range(B.shape[1]):
c[i,k] = 0
for j in range(B.shape[0]):
n = A[i,j] * B[j,k]
c[i,k] += n
return c
```

Now, let us create the below function (`multiply_vector`

) which takes two arrays as input and computes their **multiplication using NumPy's vector multiplication way**.

```
def multiply_vector(A, B):
return A @ B
```

Let us create two randomly generated 100x100 matrices - `X`

and `Y`

- to test the above functions

```
X = np.random.random((100, 100))
Y = np.random.random((100, 100))
```

Now execute the below command (`timeit`

) in Jupyter, which will output you the time taken by each of these functions

```
%timeit multiply_loops(X, Y)
%timeit multiply_vector(X, Y)
```

**Note - **Having trouble with the assessment engine? Follow the steps listed
here

XP

Checking Please wait.

Success

Error

No hints are availble for this assesment

Answer is not availble for this assesment

## Loading comments...