Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | None | 0 0
  1. #Сергеева, билет № 16
  2.  
  3. def get_season(string):
  4.     day, month, year = map(int, string.split('.'))
  5.     if day < 1 or day > 31 or month < 1 or month > 12:
  6.         return 'Ошибка в дате'
  7.     if month == 12 or month <= 2:
  8.         return 'Зима'
  9.     elif month >= 2 and month <= 5:
  10.         return 'Весна'
  11.     elif month >= 6 and month <= 8:
  12.         return 'Лето'
  13.     elif month >= 9 and month <= 11:
  14.         return 'Осень'
  15.    
  16. date_string = "17.15.21, 18.06.56, 2.12.99"
  17. dates = date_string.split(',')
  18.  
  19. win_count = spr_count = sum_count = aut_count = 0
  20.  
  21. for date in dates:
  22.     if get_season(date) == 'Зима':
  23.         win_count += 1
  24.     elif get_season(date) == 'Весна':
  25.         spr_count += 1
  26.     elif get_season(date) == 'Лето':
  27.         sum_count += 1
  28.     elif get_season(date) == 'Осень':
  29.         aut_count += 1
  30.        
  31. print('время года', 'количество', sep='\t')
  32.  
  33. print('Зима', win_count, sep='\t')
  34. print('Весна', spr_count, sep='\t')
  35. print('Лето', sum_count, sep='\t')
  36. print('Осень', aut_count, sep='\t')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement