定义一个Student类,
属性: 姓名(Name)、年龄(age)、年级(grade)、英语成绩(English)、数学成绩(Math)、物理成绩(physical)
方法: 获取总成绩、获取三门学科的平均分、按照优(>90)良(>85)差(<60)评价成绩等级
class St:
def init(self,name,age,grade,english,yuwen,shuxue,):
self.name = name
self.age = age
self.english = english
self.yuwen = yuwen
self.shuxue = shuxue
self.grade = grade
def st_cj(self):
ss = ("姓名:%s\n年龄:%s\n年级:%s\n英语成绩:%s\n语文成绩:%s\n数学成绩:%s" %(self.name,self.age,self.grade,self.english,self.yuwen,self.shuxue))
return ss
def st_pj(self):
aa = self.english + self.shuxue + self.yuwen
print("平均成绩:",aa)
def st_z(self):
cc = self.english + self.shuxue + self.yuwen
print("总成绩:",cc)
def st_uu(self):
if (self.english + self.shuxue + self.yuwen) /3 >= 90:
print("你的成绩是 优")
elif (self.english + self.shuxue + self.yuwen) /3 >= 85:
print("你的成绩是 良")
else:
print("你的成绩是 差")
bb = St("李小白",18,9,84,92,94)
print(bb.st_cj())
bb.st_z()
bb.st_pj()
bb.st_uu()