HalltapePassBot
106 строк · 3.6 Кб
1def end_of_word(number):2word = 'символ'3dict_word_ends = {'end': ['', 'а', 'ов']}4if number % 10 == 1 and number not in range(11, 20): # 15word += dict_word_ends['end'][0]6elif number % 10 in (2, 3, 4): # 47word += dict_word_ends['end'][1]8elif number % 10 in (0, 5, 6, 7, 8, 9) or number in range(11, 20):9word += dict_word_ends['end'][2]10return word11
12
13def period_result(period):14dict_period = {'seconds': 'секунд',15'minutes': 'минут',16'hours': 'час',17'days': 'д',18'years': '',19'century': 'век'}20
21dict_ends = {'seconds': ['', 'а', 'ы'],22'minutes': ['', 'а', 'ы'],23'hours': ['ов', '', 'а'],24'days': ['ней', 'ень', 'ня'],25'years': ['лет', 'год', 'года'],26'century': ['ов', '', 'а']}27
28if period // 3600 // 24 // 365 // 100 > 60000000:29result = True30return result31if period < 60:32word = dict_period['seconds']33elif 60 <= period < 3600:34word = dict_period['minutes']35period = period // 60 # Minutes Count36elif 3600 <= period < (24 * 3600):37word = dict_period['hours']38period = period // 3600 # Hours Count39elif 24 * 3600 <= period < (24 * 3600) * 365:40word = dict_period['days']41period = period // 3600 // 24 # Days Count42elif ((24 * 3600) * 365) <= period < ((24 * 3600) * 365 * 100):43word = dict_period['years']44period = period // 3600 // 24 // 365 # Years Count45elif period >= ((24 * 3600) * 365 * 100):46word = dict_period['century']47period = period // 3600 // 24 // 365 // 100 # Centuries Count48# 1549if int(period) % 10 in (0, 5, 6, 7, 8, 9) or int(period) in range(11, 20):50if word == dict_period['seconds']:51word += dict_ends['seconds'][0]52
53if word == dict_period['minutes']:54word += dict_ends['minutes'][0]55
56if word == dict_period['hours']:57word += dict_ends['hours'][0]58
59if word == dict_period['days']:60word += dict_ends['days'][0]61
62if word == dict_period['years']:63word += dict_ends['years'][0]64
65if word == dict_period['century']:66word += dict_ends['century'][0]67
68elif int(period) % 10 == 1 and int(period) not in range(11, 20): # 169if word == dict_period['seconds']:70word += dict_ends['seconds'][1]71
72if word == dict_period['minutes']:73word += dict_ends['minutes'][1]74
75if word == dict_period['hours']:76word += dict_ends['hours'][1]77
78if word == dict_period['days']:79word += dict_ends['days'][1]80
81if word == dict_period['years']:82word += dict_ends['years'][1]83
84if word == dict_period['century']:85word += dict_ends['century'][1]86
87elif int(period) % 10 in (2, 3, 4): # 488if word == dict_period['seconds']:89word += dict_ends['seconds'][2]90
91if word == dict_period['minutes']:92word += dict_ends['minutes'][2]93
94if word == dict_period['hours']:95word += dict_ends['hours'][2]96
97if word == dict_period['days']:98word += dict_ends['days'][2]99
100if word == dict_period['years']:101word += dict_ends['years'][2]102
103if word == dict_period['century']:104word += dict_ends['century'][2]105result = str(f'{period:,}') + ' ' + word106return result107