Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Person:
- def __init__(self, name="", age=0):
- self.name = name
- self.age = age
- def info(self):
- print(f"имя = {self.name}, возраст = {self.age}")
- class Student(Person):
- def __init__(self, name="", age=0, average_grade=0.0):
- super().__init__(name, age)
- self.average_grade = average_grade
- def scholarship(self):
- if 4.0 <= self.average_grade <= 5.0:
- print(f"Студент {self.name} получает стипендию")
- else:
- print(f"Студент {self.name} не получает стипендию")
- if __name__ == "__main__":
- student1 = Student('Иван Иванович', 20, 3.5)
- student2 = Student('Иван Степанович', 21, 4.0)
- student3 = Student('Иван Фомич', 22, 2.0)
- student4 = Student('Иван Кузьмич', 23, 5.0)
- print(student1.scholarship())
- print(student2.scholarship())
- print(student3.scholarship())
- print(student4.scholarship())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement