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:
![Write a function named random_factor that returns a random integer. The function should have one argument](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2023/09/6512c0a8831d6_1695727778718.jpg)
![Notes The Unicode value for the division symbol (+) is u00F7. You can enter this value into a python string](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2023/09/6512c0be97a49_1695727801025.jpg)
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...
-
Why are yields higher on loan sales than on commercial paper issues with similar maturity and issue size?
-
Provide three efferences between service and manufacturing operations make an of a company that provides both goods and services. Describe the goods and the service vements this business (3 marks)
-
Describe the classic theories of international trade. Which theories do you believe are relevant today? LO.1
-
Gladmark Company produces two types of get-well cards: scented and regular. Drivers for the four activities are as follows: The following activity data have been collected: Inspecting products...
-
Total 60 000 $9 60 000 $960000 22:50 . Andy Leaf is a careless bookkeeper. He is having a terrible time getting his trial Preparing a trial balance from balance to balance. Andy has asked for your...
-
An end loader for a small garden tractor is shown. All connections are pinned. The only significant weight is W . (a) Draw six FBDs, one each for members BC, DG, and AEF , plate CDE, hydraulic...
-
Turning the Tables A table is made from a top, 4 legs, 4 plastic caps and 8 metal hinges. Wood cost $1.40 per board foot. Metal cost $2.50 per pound. Plastic for caps cost $3.00 per kilogram. Each...
-
A company must decide between scrapping or reworking units that do not pass inspection. The company has 16,000 defective units that have already cost $132,000 to manufacture. The units can be sold as...
-
according to the phase rule, the triple point of a pure substance is A. invariant B. u nivariant C. bivariant D. none of the above
-
33. If the equipment in the previous question had sold for $15,000, the correct entry would be: a. Cash debit $15,000. Gain credit $3,000. $12,000 Equipment credit b. Cash debit $15,000. Debit a loss...
-
The banks play a central role in financial intermediation in New Zealand. 1.What is financial intermediation? Who performs it? and why is it important? 2.What is Qualitative Asset transformation...
-
Consider the following information attributed to the material management department Budgeted usage of materials - handling labor - hours 3,700 Budgeted cost pools: Fixed costs $166,500 Variable costs...
-
your company currently has $ 1 0 0 0 par, 6 . 0 0 % coupon bonds with 1 0 years to maturity and a price of $ 1 , 0 7 6 . 7 5 . If you want to issue new 1 0 year coupon bonds at par, what coupon rate...
-
CRUZ, INC. Comparative Balance Sheets December 31, 2015 CRUZ, INC. Income Statement For Year Ended December 31, 2015 Required Use the indirect method to prepare the cash provided or used from...
-
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...
-
For 2004 Stoneland Corporation re- ported net income $24,000; net sales $400,000; and average shares outstanding 6,000. There were no preferred stock dividends. What was the 2004 earnings per share?...
-
Sue Leonard, the president of Leon Company, is pleased. Leon substantially increased its net income in 2004 while keeping its unit inventory relatively the same. Dan Noonan, chief accountant,...
-
(a) What are generally accepted accounting princi- ples (GAAP)? (b) What body provides authoritative support for GAAP? AppendixLO1
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App