Thursday, 9 August 2018

Python Examination Report Question 01

Given the names and marks of n=9 students in the course Python Programming.
(a) Calculate their grades (0-49 = F, 50-60=C, 65-79 = B, 80-100 = A)
(b) Calculate the minimum and maximum.

INPUT:
name = ['Susan','May','John', 'Jay', 'Liz','Jason', 'Wen','Bin','Max','Poh','Chong','Adam']
mark = [45, 75, 53, 64, 70, 40, 85, 72, 50, 64, 85, 90]
n= len(name)
print ('\tEXAMINATION RESULTS\n')
print ('\tPYTHON PROGRAMMING\n')
print ('No.  \tStudent name  \tMark \tGrade')
for i in range(n):
   if mark [i] < 50:
       grade='F'
   elif mark[i] <65:
       grade='C'
   elif mark[i] <80:
       grade='B'
   
   else:
       grade='A'
       
   print ('%d    \t%s \t\t%d  \t%s' % (i+1, name[i], mark[i], grade))
print('Min of mark',min(mark))

print ('Max of mark',max(mark))


OUTPUT:
   EXAMINATION RESULTS

   PYTHON PROGRAMMING

No. Student name Mark Grade
1   Susan        45 F
2   May         75 B
3   John         53 C
4   Jay         64 C
5   Liz 70 B
6   Jason        40 F
7   Wen         85 A
8   Bin         72 B
9   Max         50 C
10  Poh         64 C
11  Chong        85 A
12  Adam         90 A
Min of mark 40
Max of mark 90

No comments:

Post a Comment