dimanche 16 février 2020

Write a function called randomization that takes as input a positive integer n, and returns A, a random n x 1 Numpy array

Write a function called randomization that takes as input a positive integer n, and returns A, a random n x 1 Numpy array.

Below is what I have but it's not working... Please help.

import numpy as np

def randomization(n):
    if n>0 and n==int:
        A=np.random.random([n, 1])
    print(A)
x=int(input("enter a positive number: "))
r=randomization(x)
print(r)

If i run this i get a msg saying "local vatiable 'A' referenced before assigment". please help.




Aucun commentaire:

Enregistrer un commentaire