Given the code that reads a list of integers, complete the number_guess() function, which should choose...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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) 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)
Expert Answer:
Answer rating: 100% (QA)
Heres the completed numberguess function and the main part of the code python TODO Imp... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Consider a 30 year, $150,000 fixed-rate, monthly payment mortgage with a 3.60% contract rate. If all payments are made precisely as scheduled, during years 6 through 17, what is the: 1) total amount...
-
9. Determine the next three terms of the sequence. Explain your reasoning. (4 marks) a. 1 2 3 4 2'5'8'11 b. 1, -8, 27, -64, 125......... 10. A population of rabbits if left unchecked will triple...
-
Transform the E-R model of project2 into a relational model. TransactionNo Date Hired Education Employee Address NumberOfItems Email 100 MemberD Name Transaction D Member TypeName Member Classify...
-
A score of X = 75 is measured in a population with a mean of = 100. A z-score of z = +1.50 is calculated. Without knowing the standard deviation, explain why the z-score of z = +1.50 is incorrect.
-
A closed cylinder is divided into two rooms by a frictionless piston held in place by a pin. Room A has 10 L air at 100 kPa, 30C, and room B has 300 L saturated water vapor at 30C....
-
To what extent, if any, do the prospective financial gains of the banks' shareholders represent transfers of value from other claimholders, such as bank customers, employees, and communities in which...
-
Provide examples for composite and collection objects. How do they differ?
-
As in Exercise 1, for each of the following situations, write the null and alternative hypotheses in terms of parameter values. a) A recent UMass-Amherst study found that seat-belt compliance in...
-
The following table shows a data set and the number of times each point is misclassified during a run of the perceptron algorithm (with offset 00). 0 and 60 are initialized to zero. ix (i) y() times...
-
Paper Company acquired 100 percent of Scissor Company's outstanding common stock for $370,000 on January 1, 2008, when the book value of Scissor's net assets was equal to $370,000, including...
-
A particle of mass m is moving in a central potential F(x)=(a>0) with total energy 'E' and angular momentum 'L'. The distance of minimum approach of the particle from the force center is equal to....
-
Shirley Swift transferred property with an adjusted basis of \(\$ 24,000\) and a fair market value of \(\$ 18,000\) to Alex Corporation in exchange for 100 shares of its Section 1244 stock. Three...
-
Find the osmotic pressure of a solution of 0.5 g of sucrose (C12H22O11) in 500 g water at 25C and 1 bar.
-
You have been assigned to perform tests of controls on the sales system at EDB Ltd. as part of the December 31, 2023, audit. EDB is a wholesaler of bathroom supplies such as vanity units, toilets,...
-
Consider two semiconductors, one made of Si and the other made of Ge. Both are at room temperature and doped with 10 7 phosphorous atoms. (a) Which semiconductor has the greater number of free...
-
Assume that the real risk-free rate is r* = 2% and the average expected inflation rate is 3% for each future year. The DRP and LP for Bond X are each 1%, and the applicable MRP is 2%. What is Bond Xs...
-
Write a program in C++ that accepts the base and height of a right-angle triangle from the user and displays the area of the triangle. (Hint: Formula for area of right angle triangle =...
-
Prairie Outfitters, Inc., a retailer, accepts paymnent through credit cards. During August, credit card sales amounted to $12,000. The processor charges a 3% fee. Assuming that the credit card...
-
Janie graduates from high school in 2012 and enrolls in college in the fall. Her parents pay $4,000 for her tuition and fees. a. Assuming Janie's parents have AGI of $170,000, what is the American...
-
Jenny earns $34,500 in 2012. Calculate the FICA tax that must be paid by: Jenny: ..............................Soc,Sec. ..................$______________...
-
Walter, a single taxpayer, purchased a limited partnership interest in a tax shelter in 1985. He also acquired a rental house in 2012, which he actively manages. During 2012, Walter's share of the...
-
Is an oscillating object in translational equilibrium?
-
If you photograph a flock of birds taking off from ground level, some of the wings will be blurred in the photograph even though the bodies are in focus. In which wing positions are the wings least...
-
Plot kinetic energy and potential energy as a function of time for the cart in Figure 15. 2. Data from Figure 15. 2 (a) t=0 5=0 (b) 0.09 s (c) 0.18 s x=0 E (d) 0.27 s E K U K U KU KU
Study smarter with the SolutionInn App