dimanche 16 février 2020

Write a function called operations that takes as input two positive integers h and w, makes two random matrices A and B, of size h x w

I am trying to solve below practice question and stuck.

Q> Write a function called operations that takes as input two positive integers h and w, makes two random matrices A and B, of size h x w, and returns A,B, and s, the sum of A and B.

import numpy as np
def operations(h, w):
    if h>0 and w>0 and type(h)==int and type(w)==int:
        A = np.random.rand(h, w)
        B = np.random.rand(h, w)
        s = (A, B, A+B)
        return A
        return B
        return s
x=int(input("Enter a positive number for x: "))
y=int(input("Enter a positive number for y: "))
r=operations(x, y)
print(r)



Aucun commentaire:

Enregistrer un commentaire