In this python numpy program, we will generate random numbers between 1-2 using NumPy.
Steps to solve the program
- From the numpy library import random.
- Generate random numbers between 1-2 using random.rand().
- Use for loop with the range function to generate 5 numbers.
- Print the output.
from numpy import random
for i in range(5):
rand_num = random.rand()
print(rand_num)
Output :
0.9108111865486636
0.6770944961821627
0.4528420505050911
0.7668031795361783
0.4633483035604695