write python program for the following
Answers
i=0
marks=[0,0,0,0,0]
s=0
while i<5:
print "Enter marks of subject number",i
marks[i]=int(raw_input())
s=s+marks[i]
i=i+1
avg=s/5
print 'average marks :',avg
if avg>=81 and avg<=100:
print('Grade:A+')
elif avg>=61 and avg<=80:
print('Grade:B+')
elif avg>=41 and avg<=60:
print('Grade:C+')
elif avg>=0 and avg<=40:
print('Grade:F')
Following Program from Python
Output:
Enter mark1:85
Enter mark2:96
Enter mark3:32
Enter mark4:54
Enter mark5:17
C+
Explanation:
Following are the program in the Python Programming Language:
#set variable and initialize to 0
total=0
#set for loop to get input and sum that inputs
for i in range(0,5):
inp = int(input("Enter mark{}:".format(i+1)))
total+=inp
#set variable to store the average of the sum
avg=total/5
#set the if conditions to check the grades of the students
if avg<=100 and avg>=81:
print("A+")
elif avg>=61:
print("B+")
elif avg>=41:
print("C+")
elif avg>=0:
print("F")
Following are the description of the program:
- Set a variable 'total' and initialize it to 0.
- Set the for loop to print to get marks from the user and find the sum of that marks, store it into the variable 'total'.
- Then, set variable 'avg' that stores the average of the sum.
- Finally, set the if-elif conditional statements to check the average of the student and print its grade.
Learn More:
brainly.in/question/11062269