Advertisement
JmihPodvalbniy

Untitled

Oct 16th, 2024
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | Software | 0 0
  1. ### Дз от 09.10.2024г.
  2.  
  3. #1)
  4. class Mammal:
  5.  
  6.     def give_birth(self):
  7.         return 'Я даю жизнь'
  8.  
  9. class Flying:
  10.  
  11.     def fly(self):
  12.         return 'Я летаю'
  13.  
  14. class Bat(Mammal, Flying):
  15.  
  16.     def give_birth_bat(self):
  17.         return 'Я летучая мышь, я даю жизнь'
  18.  
  19. """Создание экземпляра"""
  20. Bat1 = Bat()
  21.  
  22. """Тестирование классов"""
  23. print(Bat1.give_birth_bat())
  24. print(Bat1.give_birth())
  25. print(Bat1.fly())
  26.  
  27. #2)
  28. class Robot:
  29.  
  30.     def power_on(self):
  31.         return 'Робот включён'
  32.  
  33. class Solider:
  34.  
  35.     def fight(self):
  36.         return 'Солдат сражается'
  37.  
  38. class BattleRobot(Robot, Solider):
  39.  
  40.     def power_on_br(self):
  41.         return 'Боевая машина включена'
  42.  
  43. Robot1 = BattleRobot()
  44.  
  45. print(Robot1.power_on())
  46. print(Robot1.fight())
  47. print(Robot1.power_on_br())
  48.  
  49.  
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement