Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Сергеева, билет № 16
- def get_season(string):
- day, month, year = map(int, string.split('.'))
- if day < 1 or day > 31 or month < 1 or month > 12:
- return 'Ошибка в дате'
- if month == 12 or month <= 2:
- return 'Зима'
- elif month >= 2 and month <= 5:
- return 'Весна'
- elif month >= 6 and month <= 8:
- return 'Лето'
- elif month >= 9 and month <= 11:
- return 'Осень'
- date_string = "17.15.21, 18.06.56, 2.12.99"
- dates = date_string.split(',')
- win_count = spr_count = sum_count = aut_count = 0
- for date in dates:
- if get_season(date) == 'Зима':
- win_count += 1
- elif get_season(date) == 'Весна':
- spr_count += 1
- elif get_season(date) == 'Лето':
- sum_count += 1
- elif get_season(date) == 'Осень':
- aut_count += 1
- print('время года', 'количество', sep='\t')
- print('Зима', win_count, sep='\t')
- print('Весна', spr_count, sep='\t')
- print('Лето', sum_count, sep='\t')
- print('Осень', aut_count, sep='\t')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement