Advertisement
ProgNeo

Untitled

May 23rd, 2022
800
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.23 KB | None | 0 0
  1. # Первое заданиее
  2. def is_year_leap(year) -> bool:
  3.     return year % 4 == 0
  4.  
  5. print(is_year_leap(2000))
  6.  
  7. # Второе задание
  8. def season(month) -> str:
  9.     if month == 12 or month == 1 or month == 2:
  10.         return "Winter"
  11.     elif month == 3 or month == 4 or month == 5:
  12.         return "Spring"
  13.     elif month == 6 or month == 7 or month == 8:
  14.         return "Summer"
  15.     elif month == 9 or month == 10 or month == 11:
  16.         return "Autumn"
  17.     elif month == 0 or month > 12:
  18.         return "Wrong input"
  19.    
  20. print(season(12))
  21.  
  22. # Словарь с машинами
  23. class Car:
  24.     def __init__(self, model, body, engine_capacity, cost, color, country):
  25.         self.model = model
  26.         self.body = body
  27.         self.engine_capacity = engine_capacity
  28.         self.cost = cost
  29.         self.color = color
  30.         self.country = country
  31.     def info(self):
  32.         print(f"{self.model}, {self.body}, {self.engine_capacity}, {self.cost}, {self.color}, {self.country}")
  33.  
  34.  
  35. cars = dict()
  36. cars["Nissan"] = []
  37. cars["Toyota"] = []
  38. cars["Subaru"] = []
  39. cars[""] = []
  40. cars["Mazda"] = [Car("CX-5", "кроссовер", "2,2л", "2645000руб", "красный", "Япония")]
  41. cars["Mazda"][0].info()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement