Competitive Python Programming Questions |
In the article, we will write code to find out the percentage using Python programming language.
If you are looking for Python Tutorial then it's here.
n = int(input('Number of Subjects: '))
totalMarks = 0
print('Enter Marks')
for i in range(1,n+1):
marks = float(input('Subject ' + str(i) + ': '))
assert marks >=0 and marks <=100
totalMarks += marks
percentage = totalMarks/n
print('Percentage is: ', percentage)
Now, Run the above Python program. You will get an output something like this:
Number of Subjects: 4
Enter Marks
Subject 1: 80
Subject 2: 90
Subject 3: 90
Subject 4: 80
Percentage is: 85.0
Comments
Post a Comment