0

How do I make a grade computation through Python?

We need to compute grades using Python, but there is a problem with my code and I don't know what it is. Here is the code: # midterm grade # 3 quizzes, 2 homework, 1 term exam # User Inputs print(" Midterm Grade Computation ") q1=int(input ('Enter Quiz 1 Score (20 points): ')) q2=int(input ('Enter Quiz 2 Score (30 points): ')) q3=int(input ('Enter Quiz 3 Score (10 points): ')) hm1=int(input ('Enter Homework 1 Score (20 points): ')) hm2=int(input ('Enter Homework 2 Score (40 points): ')) term_exam=int(input ('Enter Midterm Exam Score (60 points): ')) # Computation qtotal = q1 + q2 +q3 qtotal_percent=(qtotal/60) * 100 hwtotal = hw1 + hw2 hw_percent=(hw/60) * 100 term_exam_percent=(term_exam/60) * 100 grade = (0.30 * qtotal) + (0.20 * hwtotal) + (0.50 * term_exam) #output print("Midterm Grade" + str(grade)) PLEASE HELP ME FIX IT

18th Oct 2022, 12:17 AM
Elljay
Elljay - avatar
10 Answers
+ 2
Well, without the link to your code in the question description, I don't know either...
18th Oct 2022, 2:16 AM
Emerson Prado
Emerson Prado - avatar
+ 1
you have variable naming errors.
18th Oct 2022, 4:39 AM
Bob_Li
Bob_Li - avatar
+ 1
Thank you for helping!
18th Oct 2022, 4:43 AM
Elljay
Elljay - avatar
+ 1
Probably good to add max value checking so that the inputs would be within bounds to avoid crazy results.
18th Oct 2022, 4:46 AM
Bob_Li
Bob_Li - avatar
+ 1
#set all to 100 q1=q2=q3=hw1=hw2=term_exam=100 print(" Midterm Grade Computation ") while 20<q1: q1=int(input ('Enter Quiz 1 Score (20 points): ')) while 30<q2: q2=int(input ('Enter Quiz 2 Score (30 points): ')) while 10<q3: q3=int(input ('Enter Quiz 3 Score (10 points): ')) while 20<hw1: hw1=int(input ('Enter Homework 1 Score (20 points): ')) while 40<hw2: hw2=int(input ('Enter Homework 2 Score (40 points): ')) while 60<term_exam: term_exam=int(input ('Enter Midterm Exam Score (60 points): ')) # Computation qtotal = q1 + q2 +q3 hwtotal = hw1 + hw2 qtotal_percent=(qtotal/60)*100 hw_percent=(hwtotal/60)*100 term_exam_percent=(term_exam/60)*100 grade = (0.30 * qtotal_percent) + (0.20 * hw_percent) + (0.50 * term_exam_percent) #output print("Midterm Grade" + str(grade))
18th Oct 2022, 5:14 AM
Bob_Li
Bob_Li - avatar
0
I've edited it already.
18th Oct 2022, 2:23 AM
Elljay
Elljay - avatar
0
# midterm grade # 3 quizzes, 2 homework, 1 term exam # User Inputs print(" Midterm Grade Computation ") q1=int(input ('Enter Quiz 1 Score (20 points): ')) q2=int(input ('Enter Quiz 2 Score (30 points): ')) q3=int(input ('Enter Quiz 3 Score (10 points): ')) hw1=int(input ('Enter Homework 1 Score (20 points): ')) hw2=int(input ('Enter Homework 2 Score (40 points): ')) term_exam=int(input ('Enter Midterm Exam Score (60 points): ')) # Computation qtotal = q1 + q2 +q3 qtotal_percent=(qtotal/60) * 100 hwtotal = hw1 + hw2 hw_percent=(hwtotal/60) * 100 term_exam_percent=(term_exam/60) * 100 grade = (0.30 * qtotal) + (0.20 * hwtotal) + (0.50 * term_exam) #output print("Midterm Grade" + str(grade))
18th Oct 2022, 4:39 AM
Bob_Li
Bob_Li - avatar
0
How do I add that?
18th Oct 2022, 4:47 AM
Elljay
Elljay - avatar
0
Thanks a lot!
18th Oct 2022, 5:32 AM
Elljay
Elljay - avatar