Advertisement
Chl_Snt

№21. Классы: Конец

Feb 28th, 2023
656
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. class Automatic:
  2.     def __init__(self):
  3.         print("Началась инициализация!")
  4.         self.time = 30
  5.         self.name = "Будильник"
  6.  
  7.  
  8. duzz = Automatic()
  9.  
  10.  
  11.  
  12.  
  13.  
  14. class Parrot:
  15.     def __init__(self, color, size):
  16.         self.color = color
  17.         self.size = size
  18.  
  19.     def chirik(self):
  20.         print(f"«Чирик-Чирик!» — сказал {self.size} {self.color} попугай." )
  21.  
  22.  
  23. kesha = Parrot("зелёный", "маленький")
  24. kesha.chirik()
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34. trip = {
  35.     13: ("Гостиный Двор", "ГДК", "Магазин Гипер", "Галерея"),
  36.     25: ("Парк Победы", "Улица Ленина", "Главная площадь", "Речное депо")
  37. }
  38.  
  39. class Bus:
  40.     def __init__(self, trip):
  41.         self.trip = trip
  42.  
  43.     def navigator(self, stop):
  44.         line = trip[self.trip]
  45.         print(f"Автобус №{self.trip} прибыл на остановку {line[stop]}")
  46.  
  47.  
  48. go = Bus(13)
  49. speedy = Bus(25)
  50. for num in range(4):
  51.     go.navigator(num)
  52.     speedy.navigator(num)
  53.  
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement