Write, test and debug a program to calculate and output the minimum, maximum, an
ID: 3543187 • Letter: W
Question
Write, test and debug a program to calculate and output the minimum, maximum, and average of a list of positive test scores. Ask the user how many scores s/he i ntends to enter. Assume exactly that many scores will be entered one per line. Prompt for each score. Here is the example program dialog:But you cannot use lists!
Enter the total number of scores: 4 Enter the scores: Score 1 10 Score 2 36 Score 3 5.5 Score 4 0.5 The minimum is: 0.5 The maximum is: 36 The average is: 26 When your program is working correctly, run it with this set of seven values: 89, 78, 90, 76, 70, 88, 79
Part2 - Write, test and debug a program which asks the user to enter three floating point numbers and then reports the largest and the smallest of these values. Here is the example program dialog: Enter the first number: 43.5 Enter the second number: 110.2 Enter the third number 35 The smallest of the va lues is: 35 The largest of the values is: 110.2 When your program is working correctly, run it four times, using these value sets for the input: 20.5, 14.3, and 90.9 12.5, 25.75, and 30.8 55.7, 30.4, and 34.5 110.2, 43.5 and 35 Write, test and debug a program to calculate and output the minimum, maximum, and average of a list of positive test scores. Ask the user how many scores s/he i ntends to enter. Assume exactly that many scores will be entered one per line. Prompt for each score. Here is the example program dialog:
But you cannot use lists!
Enter the total number of scores: 4 Enter the scores: Score 1 10 Score 2 36 Score 3 5.5 Score 4 0.5 The minimum is: 0.5 The maximum is: 36 The average is: 26 When your program is working correctly, run it with this set of seven values: 89, 78, 90, 76, 70, 88, 79
Part2 - Write, test and debug a program which asks the user to enter three floating point numbers and then reports the largest and the smallest of these values. Here is the example program dialog: Enter the first number: 43.5 Enter the second number: 110.2 Enter the third number 35 The smallest of the va lues is: 35 The largest of the values is: 110.2 When your program is working correctly, run it four times, using these value sets for the input: 20.5, 14.3, and 90.9 12.5, 25.75, and 30.8 55.7, 30.4, and 34.5 110.2, 43.5 and 35
Explanation / Answer
hi......
You are close. Just a reminder, don't use sum, min, max as variable names since they are functions in Python. I like to prefix with 'my'. Start with a high mymin value (let's say 100) and make it x if x is lower. With mymax you start low (zero) and make it x if x is higher.
Once you learn about lists then you can apply methods sum(), min() and max() and your life will be simpler. For example ...
Once you get better with Python27, you will actually code this way ...
Gudluck with this......
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.