Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question # 2 : Write a program that finds the range ( difference between the smallest and largest ) of 8 positive integer numbers the

Question #2:
Write a program that finds the range (difference between the smallest and largest) of 8 positive integer numbers the user inputs inside a "for loop" with a range().
The "for" loop range() function should start at 0 and go 8.
The user should enter the numbers as integers (there should only be one input statement inside the for loop, not 8 input statements for the integers).
Before the loop starts - create variables for the largest and smallest numbers and set them equal to zero. Then inside of the loop determine the largest and smallest number. You do that with an "if" test.
When the loop ends - and you are outside the loop-determine the range (difference between the smallest and largest number).
Print the range.
Then ask the user if they want to do this again (use a while loop for this).
Don't forget comments at the top of the code.
And don't forget to test the input (integer) to make sure the code does not error out when a user enters a float or a letter. Use try and except inside the loop where you convert the input from string to int().In python please
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What is a share premium? How is it recorded?

Answered: 1 week ago

Question

Social psychologists define the need to belong as the desire to

Answered: 1 week ago