วันพุธที่ 18 พฤศจิกายน พ.ศ. 2558

Rasberry Pi.

class student : def __init__(self,name,id,score): self.name = name self.id = id self.score = score def display(self) : print "Name =>" , self.name , " ID => " , self.id , " Score => %3s" % self.score def get_sc(self): return self.score def set_sc(self,va): self.score = va def getGrade(score): if(score >=80): return "A" elif(score >=70): return "B" elif(score >=60): return "C" elif(score >=50): return "D" else: return "F" def count_G(score): gr = [0,0,0,0,0] for i in range (0,len(score),1): if getGrade(score[i].get_sc()) == "A" : gr[0] += 1 elif getGrade(score[i].get_sc()) == "B" : gr[1] += 1 elif getGrade(score[i].get_sc()) == "C" : gr[2] += 1 elif getGrade(score[i].get_sc()) == "D" : gr[3] += 1 elif getGrade(score[i].get_sc()) == "F" : gr[4] += 1 return gr; def C_grade (grade,a): gr = count_G(a) if grade == 'A' : print "Grade " , grade , " = ",gr[0] , "Person" elif grade == 'B' : print "Grade " , grade , " = ",gr[1] , "Person" elif grade == 'C' : print "Grade " , grade , " = ",gr[2] , "Person" elif grade == 'D' : print "Grade " , grade , " = ",gr[3] , "Person" elif grade == 'F' : print "Grade " , grade , " = ",gr[4] , "Person" def s_a_g (a,i): print" Grade = " ,getGrade(a[i].get_sc()) def main(): a = [student("eiei", 01, 100 ), student("kiki", 02, 79 ), student("kuku", 03, 65 ), student("mimi", 04, 51 ), student("mumu", 05, 40 ), student("jiji", 11, 100 ), student("juju", 12, 95 ), student("nini", 13, 98 ), student("nunu", 14, 97 ), student("ahah", 15, 99 )] for ei in range (0,len(a),1): a[ei].display() s_a_g (a,ei) count_G(a) C_grade ('A', a) C_grade ('F', a) main()

ไม่มีความคิดเห็น:

แสดงความคิดเห็น

Link Video Presentation Resort Managemant System Project.

Video Presentation Resort Managemant System Project. จัดทำโดย พากษ์เสียง: คุณาสิน  ทองมณี  5801012620011 ลำดับภาพ: สุพิชชา  ศรีศิริ...