Write a Python program that reads marks in six
subjects and assign grades of marks:
% Marks. Grades
> 90. O
80-90. E
70-80. A
60-70 . B
50-60. C
40-50. D
<40. F
Answers
Answer:
sub1=int(input("Enter marks of the first subject: "))
sub2=int(input("Enter marks of the second subject: "))
sub3=int(input("Enter marks of the third subject: "))
sub4=int(input("Enter marks of the fourth subject: "))
sub5=int(input("Enter marks of the fifth subject: "))
avg=(sub1+sub2+sub3+sub4+sub4)/5
if(avg>=90):
print("Grade: A")
elif(avg>=80&avg<90):
print("Grade: B")
elif(avg>=70&avg<80):
print("Grade: C")
elif(avg>=60&avg<70):
print("Grade: D")
else:
print("Grade: F")
Explanation:
1. User must enter 5 different values and store it in separate variables.
2. Then sum up all the five marks and divide by 5 to find the average of the marks.
3. If the average is greater than 90, “Grade: A” is printed.
4. If the average is in between 80 and 90, “Grade: B” is printed.
5. If the average is in between 70 and 80, “Grade: C” is printed.
6. If the average is in between 60 and 70, “Grade: D” is printed.
7. If the average is anything below 60, “Grade: F” is printed.
advertisement
Explanation:
sum=0
for i in range(6):
mrx=float(input("marks : "))
sum=sum+mrx
per=sum/6
print("Percentage : ",per)
if(per>90):
print("Grade : O")
elif(80<per<=90):
print("Grade : E")
elif(70<per<=80):
print("Grade : A")
elif(60<per<=70):
print("Grade : B")
elif(50<per<=60):
print("Grade : C")
elif(40<=per<=50):
print("Grade : D")
elif(per<40):
print("Grade : F")