From :D , 3 Months ago, written in Python for S60.
Embed
  1. #! python 3
  2. #student database as dict assuming  3 courses for eath one :D
  3. #student 1
  4. #student 2
  5. #student 3
  6. import  pprint
  7. st_dp = {'st_1':{'course_1:':{'grade': 'depug' ,'attendance':  '  ' }, 'course_2:':{'grade':'   ' ,'attendance': '   '},'course_3:':{'grade': '   ','attendance':'  '}},'st_2':{'course_1:':{'grade': '  ' ,'attendance':  '   ' }, 'course_2:':{'grade':'   ' ,'attendance': '   '},'course_3:':{'grade': '   ','attendance':'  '}},'st_3':{'course_1:':{'grade': '  ' ,'attendance':  '   ' }, 'course_2:':{'grade':'   ' ,'attendance': '   '},'course_3:':{'grade': '   ','attendance':'  '}}}
  8. #pprint.pprint(st_dp)
  9. #asking  for student attendance
  10. def attend(student_name):
  11.    for key in st_dp[student_name]:
  12.       attendance = st_dp[student_name][key]['attendance']
  13.       print ('attendance of '+ key + '= ',attendance)
  14.    return None
  15. #filtering the student by attendance %
  16. def filter(percentage):
  17.    for st in st_dp:                             #looping throught the student
  18.       for course in st_dp[st] :           #looping throught courses
  19.          attendance = st_dp[st][course]['attendance']
  20.          if  int(attendance) >=  int(percentage):
  21.             print ("student with high attendance ....")
  22.             print (st+'/n'+'attendance = ',attendance)
  23.             continue
  24.          else:
  25.             print('student with low attendance ....')
  26.             print (st+'/n'+'attendance = ',attendance)
  27.    return None
  28. # to delet ant student
  29. def  delet(student_name):
  30.    if  student_name in st_dp.keys():
  31.       del st_dp[student_name]
  32.    else :
  33.       print ("not in the data base  ...")
  34. # to add any new student or to Over write exist one
  35. def add(student_name,course,attendance,grade):
  36.    if student_name not in st_dp.keys():
  37.       st_dp[student_name]
  38.       st_dp['course_1:']= {'attendance':attendance,'grade':grade}
  39.    else:
  40.       print("already in the data base .... over writting ....")
  41.       st_dp['course_1:']= {'attendance':attendance,'grade':grade}
  42.    return None
  43. #for GPA grade  =====> i dont know how it work :D
  44.    #the following  function return the grade
  45.       #just add the calculations :D
  46. def  GPA(student_name):
  47.       for key in st_dp[student_name]:
  48.          grade = st_dp[student_name][key]['grade']
  49.       # here to do the calc :D
  50.          print ('grade of '+ key + '= ',grade)
  51.       return None
  52.  
  53. pprint.pprint(st_dp)
  54.      
  55.      
  56. attend('st_1')
  57. #filter(10)
  58. #delet('st_1')
  59. #print(st_dp)
  60.