Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a) Write a program in python that allows the user to enter the results of measurements, one measurement at a time. If what the user

a) Write a program in python that allows the user to enter the results of measurements, one measurement at a time. If what the user types in is not a number, the program should print "Invalid input" and hold continue to retrieve the next measurement. This should be done until the user writes "quit". When the user has typed quit then all the numbers that the user typed in should be printed out, with a comma in between. After that, the largest deviation from the average should be printed. To calculate the deviation of measurement x from the average ave then we use: | ave - x | / | ave | i.e. the numerical value of the difference between the measurement and the mean, divided by the numerical value of the mean. To get a percentage, we multiply this by 100 and round to a whole number. Here they could built-in functions abs (for absolute value) and round helped. b) When recording measurement results by hand, there is a risk that mistakes will be made. To help identify possible mistakes then we want to compile all measurement results which occur more than once and print them out. These repeated measurement results should are printed in ascending order with a comma between them, each number should only appear once. If measurements do not contain repeated values, the program just works exactly as in a) Examples: Measurement: 1.0 Measurement: 2.0 Measurement: 2.2.21.2.12.21 Invalid input Measurement: sljsd Invalid input Measurement: 3.0 Measurement: 10.0 Measurement: quit Measurements: 1.0, 2.0, 3.0, 10.0 Largest deviation: 150% Measurement: 9.1 Measurement: 8.9 Measurement: 7.0 Measurement: sdlj Invalid input Measurement: quit Measurements: 9.1, 8.9, 7.0 Largest deviation: 16% Measurement: 42.2 Measurement: 42.2 Measurement: 42.2 Measurement: 18.3 Measurement: 18.3 Measurement: 19.2 Measurement: 23.1 Measurement: quit Measurements: 42.2, 42.2, 42.2, 18.3, 18.3, 19.2, 23.1 Largest deviation: 44% Repeated values: 18.3, 42.2 Measurement: -17.3 Measurement: -23.9 Measurement: -19.2 Measurement: -17.3 Measurement: -23.9 Measurement: -19.2 Measurement: -21.7 Measurement: quit Measurements: -17.3, -23.9, -19.2, -17.3, -23.9, -19.2, -21.7 Largest deviation: 17% Repeated values: -23.9, -19.2, -17.3 Measurement: -10.3 Measurement: -20.1 Measurement: -30.2 Measurement: 1.5 Measurement: quit Measurements: -10.3, -20.1, -30.2, 1.5 Largest deviation: 110%

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: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

=+ What are the information and consultation requirements?

Answered: 1 week ago

Question

=+ Should the MNE belong (why, why not)?

Answered: 1 week ago