Write a program that prompts the user to enter in a series of grade values
Ask Expert

Be Prepared For The Toughest Questions

Practice Problems

Write a program that prompts the user to enter in a series of grade values

Q1 - P1 

Write a program that prompts the user to enter in a series of grade values all on the same line, with grades separated with a space.  The user will only be supplying a single line of input for the purpose of this program. 

Once the grades have been inputted, analyze them and only accept values that are valid numbers (floats or integers) between 0 and 100 (inclusive). Reject all other values. 

Finally, compute summary statistics based off the input provided, including the total number of valid grades, the average grade, the highest grade, the lowest grade and the range of grades.  Format the summary statistics to two decimal places. 

Here are two sample runnings of the program: 

Enter a series of grades between 0 and 100, separated by spaces: 100 95 92.3 apple -10 300 pear 65 85 87 93 ok alldone! 

100: is valid - accepting 

95: is valid - accepting 

92.3: is valid - accepting 

apple: this is not a number - rejecting 

-10: grade is too low - rejecting 

300: grade is too high - rejecting pear: this is not a number - rejecting 

65: is valid - accepting 

85: is valid - accepting 

87: is valid - accepting 93: is valid - accepting ok: this is not a number - rejecting alldone!: this is not a number - rejecting 

Total grades collected: 7 

Range of grades: 35.00 

Highest grade: 100.00 

Lowest grade: 65.00 

Average grade: 88.19 

Enter a series of grades between 0 and 100, separated by spaces: apple pear peach 107 -30 done! apple: this is not a number - rejecting pear: this is not a number - rejecting peach: this is not a number - rejecting 

107: grade is too high - rejecting 

-30: grade is too low - rejecting done!: this is not a number - rejecting 

Total grades collected: 0 No values collected, cannot compute statistics 

Some hints: 

Your program can only accept a single input from the user.


Think about how you can extract the grade values from a single input.  Hint: the split method may be useful here.


Once the value has been extracted you will need to test to see if that value can be turned into a numeric data type.  Hint: a try / except block may be useful here.


When you are finished collecting values you will need to perform some analysis on the valid inputs.  A list may be useful for this.


Q1 - P2 

Copy the code you wrote for part 1 (this is allowed for this part of the assignment).  Then update the program to print out the collected grades from high to low, along with the number of grades collected.  For example, if the user enters 100 90 80 70 90 you would print the following: 

* 70.0 (1) 

* 80.0 (1) 

* 90.0 (2) 

* 100.0 (1) 

Note that the grade 90 was inputted twice, which is why it has a (2) after it.  The other grades were all input only once, hence the (1) after those values. 

Q1 - P3 

Copy the code you wrote for part 1 (this is allowed for this part of the assignment).  Then update the program to output the "Grades from low to high" section of your output to a file named output.txt.  For example, assume that you were to run this program: 

Hint
Computer"Here's a Python program that fulfills all three parts of the assignment:def main():    # Part 1    grades_input = input(""Enter a series of grades between 0 and 100, separated by spaces: "")    grades = grades_input.split()    valid_grades = []    for grade in grades:        try:           ...

Know the process

Students succeed in their courses by connecting and communicating with
an expert until they receive help on their questions

1
img

Submit Question

Post project within your desired price and deadline.

2
img

Tutor Is Assigned

A quality expert with the ability to solve your project will be assigned.

3
img

Receive Help

Check order history for updates. An email as a notification will be sent.

img
Unable to find what you’re looking for?

Consult our trusted tutors.

Developed by Versioning Solutions.