# Grade Scores Calculator using Python Assignment Solution

June 20, 2024
Dr. Lauren
🇦🇺 Australia
Python
Dr. Lauren Chen, a seasoned expert with 7 years of experience, is a doctorate of Yale University. With an impressive track record of completing over 500 Python assignments, she possesses a profound understanding of complex programming concepts. Dr. Chen's dedication to excellence and her ability to simplify intricate topics make her an invaluable resource for students seeking guidance in Python programming.
Key Topics
• Assignment and Exam Scores
Tip of the day
News

## Assignment and Exam Scores

Modify the existing Python source code to: protect all numerical data input by the user, such that, entering any numerical values that are outside the acceptable range of values results in the user being repeatedly queried to enter valid values.

An acceptable range of values are as follows:

Quiz and Assessment weight factors: 5-95% each

Quiz and Assessment scores: 0-100%

To increase the probability that users will enter the proper values, be sure that your source code provides enough detail for the user to understand what you’re code is expecting.

For instance:

Enter the desired quiz weight (value only): -- is more ambiguous and is unacceptable

Enter the desired quiz weight from 5-95% (value only): -- clearer for the user provides the capability to process the grades for an entire class of students without the user having to repeatedly re-run the program for each student. The user should be able to provide the program how many students they would like to evaluate, and the program will allow the user to process the set of scores of each student in the class.

Additionally, the program should display the student number as part of the output of the average calculations using the format:

Student x of y, where x is the current student number being processed and y is the total number (Ex. Student 1 of 5:) Before completing the python assignment program terminates, output to the screen the number of students that were processed by the program, along with an overall class weighted average.

Solution

```def get_validated_input(text, low, high): inp = int(input(text + '({}-{}): '.format(low,high))) while inp < low or inp > high: print('Input not in expected range. Please try again!') inp = int(input(text + '({}-{}): '.format(low,high))) return inp print("") print("Input the Weight Factors (must total 100%):") #Creation of variables for weights and getting them values from user: quiz_weight = get_validated_input("Enter the desired quiz weight (value only)", 5, 95) assessment_weight = get_validated_input("Enter the desired assessment weight (value only)", 5, 95) #Checking (if sum of weights is not 100, the user resecives the message and chance to input weights again) while (quiz_weight + assessment_weight) != 100: print("The sum of weights is not 100. Try again!") quiz_weight = get_validated_input("Enter the desired quiz weight (value only)", 5, 95) assessment_weight = get_validated_input("Enter the desired assessment weight (value only)", 5, 95) N = get_validated_input('How many students would you like to evaluate?', 1, 10) class_weighted_average = 0 i = 1 while i <= N: print('\n\n\nStudent {} out of {}:-'.format(i, N)) i += 1 print("") print("Quiz Scores:") #Creation of variables for quiz scores and getting them values from user: quiz_score_1 = get_validated_input("Please enter the score for Quiz 1", 0, 100) quiz_score_2 = get_validated_input("Please enter the score for Quiz 2", 0, 100) quiz_score_3 = get_validated_input("Please enter the score for Quiz 3", 0, 100) quiz_score_4 = get_validated_input("Please enter the score for Quiz 4", 0, 100) print("") print("Assessment Scores:") #Creation of variables for assessment scores and getting them values from user: assessment_score_1 = get_validated_input("Please enter the Assessment 1", 0, 100) assessment_score_2 = get_validated_input("Please enter the Assessment 2", 0, 100) assessment_score_3 = get_validated_input("Please enter the Assessment 3", 0, 100) #Calculation of average values and storing them to respective variables: quiz_average = (quiz_score_1 + quiz_score_2 + quiz_score_3 + quiz_score_4) / 4 assessment_average = (assessment_score_1 + assessment_score_2 + assessment_score_3) / 3 unweighted_average = (quiz_average + assessment_average) / 2 weighted_average = quiz_average * (quiz_weight / 100) + assessment_average * (assessment_weight / 100) #Transformation of average scores to letters and storing them to respective variables: if quiz_average < 60: quiz_average_letter = "F" elif quiz_average < 70: quiz_average_letter = "D" elif quiz_average < 80: quiz_average_letter = "C" elif quiz_average < 90: quiz_average_letter = "B" else: quiz_average_letter = "A" if assessment_average < 60: assessment_average_letter = "F" elif assessment_average < 70: assessment_average_letter = "D" elif assessment_average < 80: assessment_average_letter = "C" elif assessment_average < 90: assessment_average_letter = "B" else: assessment_average_letter = "A" if unweighted_average < 60: unweighted_average_letter = "F" elif unweighted_average < 70: unweighted_average_letter = "D" elif unweighted_average < 80: unweighted_average_letter = "C" elif unweighted_average < 90: unweighted_average_letter = "B" else: unweighted_average_letter = "A" if weighted_average < 60: weighted_average_letter = "F" elif weighted_average < 70: weighted_average_letter = "D" elif weighted_average < 80: weighted_average_letter = "C" elif weighted_average < 90: weighted_average_letter = "B" else: weighted_average_letter = "A" #Displaying of average values and respective letters: print("Group Quiz average is: " + str(round(quiz_average,1)) + ", Letter Grade: " + quiz_average_letter) print("Group Assessment average is: " + str(round(assessment_average,1)) + ", Letter Grade: " + assessment_average_letter) print("The unweighted overall average is: " + str(round(unweighted_average,1)) + ", Letter Grade: " + unweighted_average_letter) print("The weighted overall average is: " + str(round(weighted_average,1)) + ", Letter Grade: " + weighted_average_letter) class_weighted_average += weighted_average class_weighted_average /= N print('\n\n\nResults processed for a total of', N, 'students') print('The class weighted overall average is:', class_weighted_average) input() #Just to click any button to exit ```

## Similar Samples

Visit ProgrammingHomeworkHelp.com to browse through our diverse collection of programming homework samples. Each example highlights our proficiency in solving coding problems across different languages and complexities. These samples serve as a testament to our dedication to delivering high-quality and tailored solutions for your academic needs.