Write an input validation loop which prevents the user from entering a number larger than 100...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write an input validation loop which prevents the user from entering a number larger than 100 or less than 0. Then, enter the appropriate numbers when prompted so you match the output under Desired Output. Click Run to check your code. Click Submit to submit your code to your instructor Submit 1 # Collect input and assign to /jelly beans/ 2 jelly beans int(input("How many jelly beans do you want? ")) 3 Run 4 5 6 7 8 9 18 11 12 13 Redo Save # Write input validation loop #jelly beans/ must be greater than 81 # and less than 100 Your Output: Please enter a number between 0 and 100 -5 Please enter a number between 0 and 100 200 You want 75 jelly beans while(jelly beans <0 or jelly beans >-100): print("Please enter a number between 0 and 100",jelly_beans) jelly beans - int (input ("How many jelly beans do you want? ")) Desired Output: # Display final result. print("You want", jelly beans, "jelly beans") How many jelly beans do you want? -5 Please enter a number between 0 and 100 How many jelly beans do you want? 200 Please enter a number between 0 and 100 How many jelly beans do you want? 75 You want 75 jelly beans Write an input validation loop which prevents the user from entering a number larger than 100 or less than 0. Then, enter the appropriate numbers when prompted so you match the output under Desired Output. Click Run to check your code. Click Submit to submit your code to your instructor Submit 1 # Collect input and assign to /jelly beans/ 2 jelly beans int(input("How many jelly beans do you want? ")) 3 Run 4 5 6 7 8 9 18 11 12 13 Redo Save # Write input validation loop #jelly beans/ must be greater than 81 # and less than 100 Your Output: Please enter a number between 0 and 100 -5 Please enter a number between 0 and 100 200 You want 75 jelly beans while(jelly beans <0 or jelly beans >-100): print("Please enter a number between 0 and 100",jelly_beans) jelly beans - int (input ("How many jelly beans do you want? ")) Desired Output: # Display final result. print("You want", jelly beans, "jelly beans") How many jelly beans do you want? -5 Please enter a number between 0 and 100 How many jelly beans do you want? 200 Please enter a number between 0 and 100 How many jelly beans do you want? 75 You want 75 jelly beans
Expert Answer:
Answer rating: 100% (QA)
mainpy 1 Collect input and assign to jellybeans 2 jelly beans intinputH... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Why is the fact that a hospital operates an emergency room open to all persons regardless of ability to pay is a significant factor the IRS considers when determining if the hospital provides a...
-
There are many different types of business messages forms, and each has its own unique traits and purpose. Every business communication situation requires analysis to determine which type of message...
-
You are asked to develop a Floppy Disk program that allows users to access a floppy disk locally mounted on a computer. You are expected to use C programming language. In your program, all file I/O...
-
What effect does a weakening in U.S dollar have on Net Income for subsidiaries of U.S companies?
-
A 90-m length of wire is suspended from two points at the same elevation that are 60 m apart. Knowing that the maximum tension in the wire is 300 N, determine (a) The sag h, (b) The total mass of the...
-
The diving bell below contains trapped air at the same pressure as the water outside. At the surface, air pressure is 100 kPa. As the bell descends, the pressure on it increases by 100 kPa for every...
-
What is a unit root test and what are its consequences?
-
Scotty's Scooters plans to sell a standard scooter for $55 and a chrome scooter for $70. Scotty's purchases the standard scooter for $30 and the chrome scooter for $40. Scotty's expects to sell one...
-
Piedmont Company segments its business into two regions North and South. The company prepared the contribution format segmented income statement as shown: Total Company North South Sales $ 8 2 5 , 0...
-
M&S Inc. uses standard costing. The actual cost of direct labor per hour is $6.25 and the standard cost of direct labor per hour is $6.00. Two budgeted direct labor hours are allowed per finished...
-
Weller Corporation Comparative Income Statement and Reconciliation is given below (dollars in thousands) This Year Last Year Sales $ 96,000 $ 91,000 Cost of goods sold 60,500 56,500 Gross margin...
-
Why might a measure of aggregate transaction balances be regarded as useful for a central bank for monetary policy purposes? What is the label given to this measure? What is the label given to a...
-
List and describe three types of financial institutions that provide indirect forms of finance. How does each intermediary transform claims?
-
Should asset 3 be selected for the portfolio discussed in question 3? Its expected return is 0.12 and its measure of risk is 0.20. The correlation between its returns and those of asset 1 is 0, and...
-
What is a bankers acceptance? Does it have any connection with L/Cs?
-
What is meant by shocks hitting commercial bank balance sheets? How do banks deal with these?
-
Explain Inter process communication (IPC) in message passing system.
-
On July 1, 2011, Flashlight Corporation sold equipment it had recently purchased to an unaffiliated company for $480,000. The equipment had a book value on Flashlights books of $390,000 and a...
-
Given the unity feedback system of Figure P11.1 with do the following: a. Use frequency response methods to determine the value of gain, K, to yield a step response with a 20% overshoot. Make any...
-
Many systems are piecewise linear. That is, over a large range of variable values, the system can be described linearly. A system with amplifier saturation is one such example. Given the differential...
-
Sketch the root locus for the unity feedback system shown in Figure P8.3, where Give the values for all critical points of interest. Is the system ever unstable? If so, for what range of K? K(s +2)...
-
Allister Company uses both debt capital and equity capital to fund new projects. The before-tax cost of debt capital is 12 percent. The cost of equity capital is 10 percent. Allister's effective tax...
-
Use an Internet search engine to identify three companies or agencies that use present worth analysis to make business decisions as evidenced in their annual reports.
-
Use the Internet to access ConocoPhillips's most recent annual report. a. What evidence do you find that ConocoPhillips continues to rely on present worth analysis in its corporate decision making?...
Study smarter with the SolutionInn App