Question
I need solution for only assignment 2. Assignment 1 is in python language. I need answer in python language Assignment 1). This week, for the
I need solution for only assignment 2. Assignment 1 is in python language. I need answer in python language
Assignment 1). This week, for the project; re-write your solution to implement functions. In other words, you are placing some of the functionality that you already have or wish to add into functions. You should have at least two functions.
Chegg people have solved this answer last week .
grades = {} def add_grade(): subject = input("Enter subject name: ") category = input("Enter category name: ") grade = float(input("Enter grade: ")) if subject not in grades: grades[subject] = {} if category not in grades[subject]: grades[subject][category] = [] grades[subject][category].append(grade) print("Grade added successfully!") def print_grades(): for subject in grades: print("Subject:", subject) for category in grades[subject]: print("\tCategory:", category) print("\tGrades:", grades[subject][category]) def calculate_final_grades(): for subject in grades: total_weighted_grade = 0 total_weight = 0 for category in grades[subject]: category_weight = float(input("Enter weight for {} category in {} subject: ".format(category, subject))) total_weight += category_weight category_grade = sum(grades[subject][category]) / len(grades[subject][category]) total_weighted_grade += (category_grade * category_weight) final_grade = total_weighted_grade / total_weight letter_grade = calculate_letter_grade(final_grade) print("Subject:", subject) print("Final Grade:", final_grade) print("Letter Grade:", letter_grade) def calculate_letter_grade(grade): if grade >= 90: return "A" elif grade >= 80: return "B" elif grade >= 70: return "C" elif grade >= 60: return "D" else: return "F"
The grades dictionary is defined outside of the functions so that it can be accessed by all three functions. Each time a grade is added, it is added to the appropriate subject and category within the grades dictionary.
Assignment 2) This week, for the project; re-write your solution to implement classes. In other words, you are to place the functions that you created from Assignment 1 into a class.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started