Computer Science, asked by AnnieStar, 11 months ago

Write a python program they inputs a student marks in 5 subjects out of 100 and print the total marks and percentage of marks​

Answers

Answered by AbhijithPrakash
56

#First of all, you'll have to make the user input the marks 5 times, so I'll be using Tuple and for loop.

a, b, c, d, e = 0, 0, 0, 0, 0 #Here I'm defining the temporary values of a,b,c,d,e.

marks = [a, b, c, d, e]  # I created a tuple.

for i in range(0, len(marks)):

 marks[i] = int(input("Enter the marks out of 100 : ")) #This will change the values of a, b, c, d, and e

total = sum(marks)

print("The total mark is ", total, "out of 500.")

percent = total/500*100

print("Percentage is ", percent, "%.")

We can also use an alternative method;

a = int(input("Enter the marks out of 100 : "))

b = int(input("Enter the marks out of 100 : "))

c = int(input("Enter the marks out of 100 : "))

d = int(input("Enter the marks out of 100 : "))

e = int(input("Enter the marks out of 100 : "))#Then I'll add all the variables

total = a+ b + c + d + e#Finding the percentage

percent = total/500*100#Printing the total and percent variable.

print("The total mark is ", total, "out of 500.")

print("Percentage is ", percent, "%.")

#Note: You can use float function instead of int for decimal value in the marks

Attachments:
Answered by MrBadGlamorous
20

Program/Source Code

Here is source code of the Python Program to take in the marks of 5 subjects and display the grade. The program output is also shown below.

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:

hii kem bhul gyii kya mujhee...

Similar questions