Home / Expert Answers / Computer Science / 11-9-lab-guess-the-random-number-given-the-code-that-reads-a-list-of-integers-complete-the-number-pa745

(Solved): 11.9 LAB: Guess the random number Given the code that reads a list of integers, complete the number ...




11.9 LAB: Guess the random number
Given the code that reads a list of integers, complete the number_guess 0 function, which s
* TODO: Import the random module
def number_guess(num):
\# TODO: Get a random number between 1-100
\# TODO: Read numbers and
11.9 LAB: Guess the random number Given the code that reads a list of integers, complete the number_guess 0 function, which should choose a random number between 1 and 100 by calling random, randint 0 and then output if the guessed number is too low, too high, or correct. Import the random module to use the random seed0 and random randint0 functions. - random seed(seed_value) seeds the random number generator using the given seed_value. - randomirandint(o,b) returns a random number between \( a \) and \( b \) (inclusive). For testing purposes, use the seed value 900 , which will cause the computer to choose the same random number every time the program runs. Ex: if the input is: \( 32 \quad 45-48.80 \) the output is: 3218 too low. Random number was 80 . 45 is too high. Random number was 30. 48 ia correct! 80 is too low. Random number was 97. * TODO: Import the random module def number_guess(num): \# TODO: Get a random number between 1-100 \# TODO: Read numbers and compare to random number if __name_. =. "_-main_-": \# Use the seed 900 to get the same pseudo random numbers every time random. seed(900) \# Convert the string tokens into integers user_input = input() tokens = user_input.split() for token in tokens: num \( =i \) int(token) number_guess(num)]


We have an Answer from Expert

View Expert Answer

Expert Answer


Source Code: import random # importing random module def number_guess(num): rand_num=random.randint(1,100) # generating a random number between 1-100
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe