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

Raspberry pi lab

class Student:
    def __init__(self,name,id,score):
        self.name=name
        self.id=id
        self.score=score
    def display(self):
        print('name :',self.name)
        print('id :',self.id)
        print('score :',self.score)
    def get_score(self):
        return self.score
    def set_socre(self,score):
        self.score=score
def setup():
    std = [Student('John',1,81),
         Student('Gase',2,80),
         Student('Joh',3,75),
         Student('Blob',4,65),
         Student('Sk',5,85)]
    count_grade('A',std)
    show_allGrade(std)
 
def find_grade(a):
    if a.get_score()>=80 and a.get_score()<=100:
        return 'A'
    elif a.get_score()>=70 and a.get_score()<80:
        return 'B'
    elif a.get_score()>60 and a.get_score()<70:
        return 'C'
    elif a.get_score()>=50 and a.get_score()<60:
        return 'D'
    elif a.get_score()<50 and a.get_score()>=0:
        return 'F'
def count_grade(a,array):
    count=0
    i=0
    while i<len(array):
        if find_grade(array[i])==a:
            count+=1
        i+=1
    print('Grade ',a,'= ',count)
def show_allGrade(a):
    i=0
    while i<len(a):
        a[i].display()
        print('Grade :',find_grade(a[i]))
        i+=1
setup()

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

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

commit เพิ่มเติม : เพื่ม userstory, bookmark

>>  add userstory ทำการเพิ่ม userstory ใน functional tests >>  add bookmark for user เพิ่มระบบ Bookmark โดยการสร้าง model ขึ...