Find a random number less than 50
Use an integer seed. Each call starts a local random generator, so repeating a call with the same seed repeats its result without changing the global random state.
Write a function named find_random_number that takes an optional random seed and repeatedly generates random integers from 0 to 100, inclusive, until it finds a number less than 50. Use a while loop and return the number found. Start from the code in Listing 1.
find_random_number (Question 1).
TipHint
assert conditionchecks a Boolean condition. A true condition produces no output; a false condition raisesAssertionError. For example,assert 2 + 3 == 5passes.Random(seed)creates a local generator.rng.randint(low, high)returns one integer from the inclusive bounds, which must satisfylow <= high. For example,rng.randint(5, 5)returns5.