You are on page 1of 2

PRACTICAL – 1

AIM:
Write a program to input name and marks in three subject to print name along with the
total and percentage.

CODING:
# Write a program to input name and marks in three subject to print name along with the
#total and percentage.

name=input('Enter your name :')


#Assuming that MM is 100
marks=[]

for i in range(3):
msg='Enter marks in subject #'+str(i+1)+' :'
m=int(input(msg))
marks.append(m)

print('-'*50)
print('Your name is :',name.upper())
print('Total is :',sum(marks))
print('Percentage is :',round(sum(marks)/len(marks),2))
print('-'*50)

OUTPUT OF THE CODE:


Enter your name :krishna singh
Enter marks in subject #1 :65
Enter marks in subject #2 :85
Enter marks in subject #3 :94
--------------------------------------------------
Your name is : KRISHNA SINGH
Total is : 244
Percentage is : 81.33
--------------------------------------------------

or you may paste screenshot of the output


VARIABLE AND FUNCTION USED:
Sno Variable / Function Name Datatype Purpose
1 name String To store name of the student
2 marks[] List To store marks in three subjects
3 i Integer To run a loop
4 append() A function to add element in a list
5 sum() A function to return sum of a list
6 upper() A function to print string in uppercase
7 round() A function to roundoff the value

You might also like