Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the code that reads a list of integers, complete the number_guess() function, which should choose a random number between 1 and 100 by

Given the code that reads a list of integers, complete the number_guess() function, which should choose a 1 # TODO: Import the random module 2 3 def number_guess(num): 4 5 6 7 8 9 if __name__

Given the code that reads a list of integers, complete the number_guess() function, which should choose a random number between 1 and 100 by calling random.randint() and then output if the guessed number is too low, too high, or correct. Import the random module to use the random.seed() and random.randint() functions. random.seed(seed_value) seeds the random number generator using the given seed_value. random.randint(a, 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 45 48 80 the output is: 32 is too low. Random number was 80. 45 is too high. Random number was 30. 48 is correct! 80 is too low. Random number was 97. Activate Windows Go to Settings to activate Windows. 1 # TODO: Import the random module 2 3 def number_guess(num): 4 5 6 7 8 9 if __name__ "__main__": 10 # Use the seed 900 to get the same pseudo random numbers every time random.seed (900) 11 12 13 14 15 16 17 18 19 # TODO: Get a random number between 1-100 # TODO: Read numbers and compare to random number == # Convert the string tokens into integers user_input input() user_input.split() main.py tokens = for token in tokens: num = int(token) number_guess(num)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Heres the completed numberguess function and the main part of the code python TODO Imp... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

consider the following recurrence relationship

Answered: 1 week ago