01
class Students():
"""定义一个学生类"""
def __init__(self,name,age):
self.anme = name
self.age = age
self.scoor = []
@staticmethod #添加一个成绩
def add_scoor():
scoor = []
chinese_scoor = int(input("语文成绩:"))
math_scoor = int(input("数学成绩:"))
english_scoor = int(input("英语成绩"))
scoor = [ chinese_scoor,math_scoor,english_scoor]
return scoor
def getname(self):
print(self.anme)
def getage(self):
print(self.age)
def get_course(self):
max = self.scoor[0]
for index in self.scoor[:]:
if max < index:
max =index
print(max)
s1 = Students("aaa",18)
s1.getage()
s1.getname()
s1.get_course()
02
class Auto:
def __init__(self,tire_num = 0,car_color= "red",car_height =0):
self.tire_num = tire_num
self.car_color = car_color
self.car_height = car_height
self.car_speed = ""
def add_speed(self):
print("汽车加速")
class CarAuto(Auto):
def __init__(self,kongtiao="111",cd ="222"):
super().__init__()
self.kongtiao = kongtiao
self.cd = cd
def add_speed(self):
super().add_speed()
print("小汽车加速")
car1 = Auto()
car1.tire_num = 4
car1.add_speed()
car2 = CarAuto()
car2.tire_num = 8
print(car2.tire_num)
car2.cd= "333"
print(car2.cd)
car2.add_speed()
03
网友评论