Given integer inputs seed, how_many, and max_num, generate a list of how_many unique random integers from 0 to max_num (inclusive). 1. Complete function unique_random_ints(how_many, max_num): a. Generate a list of how_many random integers from 0 to max_num (inclusive). b. When a random number exists in the list, a new random number must be generated; use a global variable, retries, to count the number of times an existing number is generated. c. Return the list. 2. Complete __main__: a. Initialize the random module with the seed value. b. Call unique_random_ints() to get a list of random integers. c. Output the list of random integers and the value of retries, according to the output format shown in the example below. Refer to the section on the standard library to learn more about the random module and pseudo-random numbers. Ex: If the input is: 2 5 7 the output is 0 1 5 2 4 retries=1 import random def unique_random_ints(how_many, max_num): """Return a list of how_many unique randomly generated numbers from 0 to max_num (inclusive) using seed to initialize the random module""" # Type your code here. # if __name__ == '__main__': seed = int(input()) how_many = int(input()) max_num = int(input()) # Type your code here. #

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.4: A Case Study: Rectangular To Polar Coordinate Conversion
Problem 9E: (Numerical) Write a program that tests the effectiveness of the rand() library function. Start by...
icon
Related questions
Question

Given integer inputs seed, how_many, and max_num, generate a list of how_many unique random integers from 0 to max_num (inclusive).

    1. Complete function unique_random_ints(how_many, max_num):
        a. Generate a list of how_many random integers from 0 to max_num (inclusive).
        b. When a random number exists in the list, a new random number must be generated; use a global variable, retries, to count the number of times an existing number is generated.
        c. Return the list.
   2. Complete __main__:
       a. Initialize the random module with the seed value.
       b. Call unique_random_ints() to get a list of random integers.
       c. Output the list of random integers and the value of retries, according to the output format shown in the example below.

Refer to the section on the standard library to learn more about the random module and pseudo-random numbers.

Ex: If the input is:

2
5
7

the output is

0 1 5 2 4 retries=1

 

import random

def unique_random_ints(how_many, max_num):
    """Return a list of how_many unique randomly generated numbers from
    0 to max_num (inclusive) using seed to initialize the random module"""

    # Type your code here. #


if __name__ == '__main__':
    seed = int(input())
    how_many = int(input())
    max_num = int(input())

    # Type your code here. #

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Mergesort
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning