126k views
4 votes
The user is able to input grades

and their weights, and calculates the overall final mark. The program should also output what you need to achieve on a specific assessment to achieve a desired overall mark. The program should be able to account for multiple courses as well. Lists are allowed.

Name of person
Number of courses
Course ID
Grades and Weights in various categories (Homework, Quiz, and Tests)
Enter grades until -1 is entered for each category
Final Grade before exam
Calculate to get a desired mark (using final exam)
Output all courses

1 Answer

2 votes

Answer:

Here is an example of how you could write a program to perform the tasks described:

# Store the student's name and number of courses

name = input("Enter the student's name: ")

num_courses = int(input("Enter the number of courses: "))

# Create an empty list to store the course data

courses = []

# Loop through each course

for i in range(num_courses):

# Input the course ID and initialize the total grade to 0

course_id = input("Enter the course ID: ")

total_grade = 0

# Input the grades and weights for each category

print("Enter grades and weights for each category (enter -1 to finish)")

while True:

category = input("Enter the category (homework, quiz, test): ")

if category == "-1":

break

grade = int(input("Enter the grade: "))

weight = int(input("Enter the weight: "))

# Calculate the contribution of this category to the total grade

total_grade += grade * weight

# Store the course data in a dictionary and add it to the list

course_data = {

"id": course_id,

"grade": total_grade

}

courses.append(course_data)

# Input the final grade before the exam

final_grade_before_exam = int(input("Enter the final grade before the exam: "))

User Kevin Quinzel
by
7.7k points