Hey all, I have created a simple program to try to convert letter grades into a GPA score, but my program calculations are a bit off.
Thanks!
user_grades = [] grades = str(input("Enter a grade: ('q' to end.)")) user_grades.append(grades) while grades != 'q': grades = str(input("Enter a grade: ('q' to end.)")) user_grades.append(grades) else: user_grades.pop() print(f"{user_grades}") total = 0 for grade in user_grades: if "A+" in user_grades: total += 4.0 elif "A" in user_grades: total += 4.0 elif "A-" in user_grades: total += 3.7 elif "B+" in user_grades: total += 3.3 elif "B" in user_grades: total += 3 elif "B-" in user_grades: total += 2.7 elif "C+" in user_grades: total += 2.3 elif "C" in user_grades: total += 2.0 elif "C-" in user_grades: total += 1.7 elif "D+" in user_grades: total += 1.3 elif "D" in user_grades: total += 1.0 elif "F" in user_grades: total += 0 print(f"{total}")Any help would be greatly appreciated.
Thanks!
Larz60+ write Apr-12-2023, 09:51 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
I have fixed this for you. Please use BBCode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
I have fixed this for you. Please use BBCode tags on future posts.