Write a function named random_factor that returns a random integer. The function should have one argument...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a function named random_factor that returns a random integer. The function should have one argument which specifies how many digits the random number it returns should have. Then use this function in a program that gives the user a simple division problem to solve as shown below. The main function of your program should use your random_factor function to generate a random 2 digit factor and a random 1 digit factor. The numerator of the division problem should be the product of these factors. The denominator should be the 1 digit factor. For example, if the factors are 33 and 6, the numerator is 198, the denominator is 6, and the correct answer is 33. The program should then allow the user to enter the answer. If their answer is correct, a message of congratulations should be displayed. If their answer is incorrect, a message show- ing the correct answer should be displayed. Finally, format your program to match the samples below. Since the numbers should be randomly generated from your own code, your program will display different digits than those shown in the sample. User input in the sample has been highlighted in Pappy's Purple to dis- tinguish it from the program's output, but your user input does not need to be colored. Save your program as math_quiz_login.py, where login is your Purdue login. Then submit it along with a screenshot showing 3 test runs. Be sure to include both correct and incorrect results in your screenshot. Terminal $ python math_quiz_login.py 25 +1 = 0 Sorry, the correct answer is 25. $ python math_quiz_login.py 148 # 2 ---- = 74 Great job, that's correct! $ python math_quiz_login.py 388 4 198 6 # Notes • The Unicode value for the division symbol (+) is \u00F7. You can enter this value into a python string like this Terminal $ python >>>print("\u00F7") + >>> exit() Write a function named random_factor that returns a random integer. The function should have one argument which specifies how many digits the random number it returns should have. Then use this function in a program that gives the user a simple division problem to solve as shown below. The main function of your program should use your random_factor function to generate a random 2 digit factor and a random 1 digit factor. The numerator of the division problem should be the product of these factors. The denominator should be the 1 digit factor. For example, if the factors are 33 and 6, the numerator is 198, the denominator is 6, and the correct answer is 33. The program should then allow the user to enter the answer. If their answer is correct, a message of congratulations should be displayed. If their answer is incorrect, a message show- ing the correct answer should be displayed. Finally, format your program to match the samples below. Since the numbers should be randomly generated from your own code, your program will display different digits than those shown in the sample. User input in the sample has been highlighted in Pappy's Purple to dis- tinguish it from the program's output, but your user input does not need to be colored. Save your program as math_quiz_login.py, where login is your Purdue login. Then submit it along with a screenshot showing 3 test runs. Be sure to include both correct and incorrect results in your screenshot. Terminal $ python math_quiz_login.py 25 +1 = 0 Sorry, the correct answer is 25. $ python math_quiz_login.py 148 # 2 ---- = 74 Great job, that's correct! $ python math_quiz_login.py 388 4 198 6 # Notes • The Unicode value for the division symbol (+) is \u00F7. You can enter this value into a python string like this Terminal $ python >>>print("\u00F7") + >>> exit()
Expert Answer:
Answer rating: 100% (QA)
It seems you want to create a Python program that generates math quiz questions and checks if the ... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
Sunny Ltd produces four products. Information on each product is shown below: A B C D Budgeted sales (units) 4,000 2,000 3,000 1,000 Selling prices $60 $45 $52 $95 Production costs per unit Direct...
-
(1) (a) Discretize the 2D Poisson equation Vu(x, y) = Uxx + Uyy = = p(x, y) with second-order accurate central differences with Ax = the given charge density. Ay=h. p(x, y) is (b) Express uij in...
-
Implement two versions of the RESULT(s, a) function for the 8-puzzle: one that copies and edits the data structure for the parent node s and one that modifies the parent state directly (undoing the...
-
A spring-loaded piston/cylinder arrangement contains R-134a at 20C, 24% quality with a volume 50 L. The setup is heated and thus expands, moving the piston. It is noted that when the last...
-
On January 1 , 2 0 1 8 , when its $ 3 0 par value common stock was selling for $ 8 0 per share, a corporation issued $ 1 0 million of 1 4 % convertible debentures due in 1 0 years. The conversion...
-
Briefly explain the main differences among hierarchical, network, and relational databases.
-
Fore Farms reported a pretax operating loss of $137 million for financial reporting purposes in 2021. Contributing to the loss were (a) a penalty of $5 million assessed by the Environmental...
-
You pay $1,000 to flip a two-sided, fair coin at the local fair. If you flip 'heads', you walk away with $3,000, a return of 200%. However, if you flip 'tails', you walk away with $250, a return of...
-
There is a parcel of land next to the Playful Paws, Inc. building. Ellen, the owner of this property, approached John to discuss the idea of selling it to him. John is interested. Ellen knows that...
-
Which of the following would show information on the frequency of machine breakdowns causing lost productions? A The non-current asset register B The machine maintenance schedule C Production output...
-
You have a loan outstanding. It requires making seven annual payments of $2000 each at the end of the next seven years. Your bank has offered to allow you to skip making the next six payments in lieu...
-
Suppose you receive $180 at the end of each year for the next three years. a. If the interest rate is 9%, what is the present value of these cash flows? b. What is the future value in three years of...
-
You have just entered college and have decided to pay for your living expenses using a credit card that has no minimum monthly payment. You intend to charge $1000 per month on the card for the next...
-
You are thinking about buying a piece of art that costs $50,000. The art dealer is proposing the following deal: He will lend you the money, and you will repay the loan by making the same payment...
-
You have an investment account that started with $4000 10 years ago and which now has grown to $6000. a. What annual rate of return have you earned (you have made no additional contributions to the...
-
Find the break-even point(s) for the revenue and cost functions below. Separate multiple answers with a comma R(x)=686.60x-7x^2 C(x)=23x+7777.49
-
Give an example of transitory income. What effect does this income have on the marginal propensity to consume?
-
Modify the TelephoneNumber class described in Exercise 6 so that it is serializable. Write a program that creates an array whose base type is TelephoneNumber by reading data from the keyboard. Write...
-
A palindrome is a word or phrase that reads the same forward and backward, ignoring blanks and considering uppercase and lowercase versions of the same letter to be equal. For example, the following...
-
Suppose that we would like to perform a bird survey to count the number of birds of each species in an area. Create a class BirdSurvey that is like one of the linked-list classes given in this...
-
What did Park Ridges 2021 statement of cash flows tell us?
-
What role do asset and debt utilization play in a businesss profitability as measured by return on equity?
-
How are common-size statements created?
Study smarter with the SolutionInn App