Write a script that plays the guess the number. Choose the number to be guessed by...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a script that plays the guess the number. Choose the number to be guessed by selecting a random integer in the range 1 to 1000 Do not reveal this number to the user. Display the prompt Guess my number between 1 and 1000 with the fewest guesses:. The player inputs a first guess. If the guess is incorrect, display Too high. Try again. or Too low. Try again. as appropriate to help the player zero in on the correct answer, then prompt the user for the next guess. When the user enters the correct answer, display Congratulations. You guessed the number!, and allow the user to choose whether to play again. In [10]: # write the script here Question 6 (2 points) Write a function that performs the factorial calculations that are common in probability. The factorial of a nonnegative integer n is written nl (pronounced "n factorial") and is defined as follows n! n (n-1) (n 2) 1. For values of n greater than or equal to 1, with 0! defined to be 1. So, 5! - 5 4 3 2 1 which is 120. Factorials increase in size very rapidly. The factorial function should receive a nonnegative integer, compute, and display its factorial. Try your script on the integers 10, 20, 30 and even larger values. In [11]: # write the function code here In [12]: # Write a program that calls the function and display the returned results. Question 7 (2 points) Write a script that estimates the value of the mathematical constant e by using the formula below. Your script can stop after summing 10 terms. The script should use the factorial function created in the Question 6. 1+ 1 1 1 1!* 2!*3! In [13]: # Write the script here Write a script that plays the guess the number. Choose the number to be guessed by selecting a random integer in the range 1 to 1000 Do not reveal this number to the user. Display the prompt Guess my number between 1 and 1000 with the fewest guesses:. The player inputs a first guess. If the guess is incorrect, display Too high. Try again. or Too low. Try again. as appropriate to help the player zero in on the correct answer, then prompt the user for the next guess. When the user enters the correct answer, display Congratulations. You guessed the number!, and allow the user to choose whether to play again. In [10]: # write the script here Question 6 (2 points) Write a function that performs the factorial calculations that are common in probability. The factorial of a nonnegative integer n is written nl (pronounced "n factorial") and is defined as follows n! n (n-1) (n 2) 1. For values of n greater than or equal to 1, with 0! defined to be 1. So, 5! - 5 4 3 2 1 which is 120. Factorials increase in size very rapidly. The factorial function should receive a nonnegative integer, compute, and display its factorial. Try your script on the integers 10, 20, 30 and even larger values. In [11]: # write the function code here In [12]: # Write a program that calls the function and display the returned results. Question 7 (2 points) Write a script that estimates the value of the mathematical constant e by using the formula below. Your script can stop after summing 10 terms. The script should use the factorial function created in the Question 6. 1+ 1 1 1 1!* 2!*3! In [13]: # Write the script here
Expert Answer:
Answer rating: 100% (QA)
Certainly here are the solutions to your questions Question 6 Function to calculate factorial def fa... View the full answer
Related Book For
Principles Of Information Security
ISBN: 9780357506431
7th Edition
Authors: Michael E. Whitman, Herbert J. Mattord
Posted Date:
Students also viewed these programming questions
-
Answer each of the following questions using complete sentences. Part I: Harper is shopping for a home and a mortgage for $175,800 with which to purchase this home. In her search, she was eligible...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
According to ValueLine estimates in Figure 1, James River’s expected annual dividend growth rate from the 91–93 to 97–99 period is 5.50%, and the next dividend (1995) is...
-
Rio Tinto is a listed company in the mining and metals production industry. Some information drawn from its 2020 annual report is shown below. Safety and health performance 2020 2019 2018 Fatalities...
-
Determine by direct integration the moment of inertia of the shaded area with respect to the y axis. = 1
-
Beech Corporation, an accrual - basis, calendar - year taxpayer, was organized and began business in June of the current calendar tax year. During the current year, the corporation incurred the...
-
What are the differences between extend and include use cases?
-
Pup Noir, a private investigation firm, investigated 90 cases in December and had the following costs: direct labor, $190 per case; and service overhead of $20,840. Service overhead for October was...
-
Jungleland, Inc., acquired 1,000 of the 4,000 shares of Clemmons Corporation for $300 each on January 1,2024 . The book value of Jungleland's share of Clemmons's identiflable net assets was $275,000...
-
Find RAB in the network in figure. ww- 6 kn 6 kN 2 kn RAB 6 B
-
Research what is expected for a business profession in regard to attire, appearance, and related behaviors. Focus on specifics that may distinguish members of a business profession from other...
-
Wilson, Player and Sharp are in partnership. They shared profits in the ratio 2:4:3. It is decided to admit Titmus. It is agreed that goodwill is worth 72,000 and that it is to be brought into the...
-
Bee, Cee and Dee have been holding preliminary discussions with a view to forming a partnership to buy and sell antiques. The position has now been reached where the prospective partners have agreed...
-
Calculate gross profit as a percentage of sales if gross profit was 70,000 and sales were 400,000.
-
What is the minimum number of times a while() loop will be executed? What is the maximum number?
-
Calculate the inventory turnover ratio if average inventory is 40,000 and cost of sales is 280,000.
-
Happy Day Company provided the following information to prepare budgets for January, February, and March 2023, including the total for the quarter. Sales were 67,000 units in December 2022....
-
Prove that the mean heat capacities C P H and C P S are inherently positive, whether T > T 0 or T < T 0 . Explain why they are well defined for T = T 0 .
-
I. Explain how it is a widely held view that these unsecured, dial-up connection points represent a substantial exposure to attack. II. Comprehend that an attacker who suspects that an organization...
-
What is the name of a nonprofit organization that focuses on the development and implementation of information security certifications? a. International Information Systems Security Certification...
-
Stress that this section of the policy provides strict guidance with respect to where technology is prohibited to be used. Predict the fact that an organization and its employees cannot be penalized...
-
You are the manager of a large department store. Over the years, youve found a strong correlation between your September sales and the number of employees youll need to hire for peak efficiency...
-
Youve been hired by your colleges alumni association to research how past contributions were associated with alumni income and years that have passed since graduation. It is found that R 2 = 0.36....
-
Financial items for George Karatsis IT Services on 31 May 2024 are presented below in alphabetical order. Required (a) Prepare a statement of financial position similar to the one in figure 2.2. (b)...
Study smarter with the SolutionInn App