Random no. generation in python.

1).Input:-
import numpy as np
y=np.random.random_sample(3)
print(y)

Output:-

2).Input:-
q=np.random.rand(2,3)
print(q)

Output:-

3).Input:
import numpy as np
y1=np.random.rand(1,10)
print("y",y1)
Hint:-To create random no. table, we can use the above 1 as to it should be only one valued digit and how many no. should be there then it is 10

Output:-

4).Input:-
import numpy as np
y2=np.random.standard_normal(12)
print("y2",y2)
Hint:-Here,12 is the length of random no.

Output:-

5).Input:-
import numpy as np
y3=5*np.random.randn(3,2)+2
print("y3,y3)
Hint:-Here,5 is sigma value and 2 (after “+”) is the value of mean.and (3,2) is as always no. of rows and no. of columns respectively.

Output:-

Allocating values:-
a).Input:-
import numpy as np
q=np.random.rand(2,2)
print("matrix=",q)
print("coresponding value=",q[1][0])
Hint:-allocating 1st value of 2nd tuple.

Output:-

Leave a Reply