mardi 4 octobre 2022

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

Instuctions, What I have tried so far, my outputComplete function unique_random_ints(how_many, max_num):

  • Generate a list of how_many random integers from 0 to max_num (inclusive).
  • 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.
  • Return the list.

Complete __main__:

  • Initialize the random module with the seed value.
  • Call unique_random_ints() to get a list of random integers.
  • Output the list of random integers and the value of retries, according to the output format shown in the example below.



Aucun commentaire:

Enregistrer un commentaire