Computer Science, asked by rudramazumdar2, 6 months ago

Which coding block can give you any random number from 100 to 200?​

Answers

Answered by REDNINJA
0

Answer:

121

You can create a random number generator in C++ by using the rand() and srand() functions that come with the standard library of C++. Such a generator can have the starting number (the seed) and the maximum value.

Answered by vishakasaxenasl
0

Answer:

Import the random module in your code and then give upper(200) and lower(100) limits. This will generate random numbers in the given range.

Follow the below code:

import random

def Rand(start, end, num):

   arr = []

   for j in range(num):

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

   return arr

num = 101

upper_limit = 200

lower_limit = 100

print(Rand(lower_limit, upper_limit, num))

Explanation:

Let's understand the code above;

  • First, we will import our random module.
  • Then we specify the range including the lower and upper limits so that random numbers can be generated within the given range.
  • randint function is pre-defined in the random module and it generates random integers.
  • All those random integers are stored in the arr list and then we return the list.

#SPJ2

Similar questions