Computer Science, asked by millan544, 1 year ago

How to generate random number b/w two values in python?

Answers

Answered by CoolBro003
0

The code in Python is :

import random

# start = starting range,

# end = ending range

# number = number of  values given

def Rand(start, end, number):

   res = []

 

   for j in range(number):

       res.append(random.randint(start, end))

 

   return res  

number = 10

start = 20

end = 40

print(Rand(start, end, number))


Example Output(as it may come different too)

[23, 20, 30, 33, 30, 36, 37, 27, 28, 38]


If you have Some more questions, then contact me at:

   Email: [email protected]

   Youtube: shorturl.at/mnB57

Similar questions