HalltapePassBot

Форк
0
/
end_of_words.py 
106 строк · 3.6 Кб
1
def end_of_word(number):
2
    word = 'символ'
3
    dict_word_ends = {'end': ['', 'а', 'ов']}
4
    if number % 10 == 1 and number not in range(11, 20):  # 1
5
        word += dict_word_ends['end'][0]
6
    elif number % 10 in (2, 3, 4):  # 4
7
        word += dict_word_ends['end'][1]
8
    elif number % 10 in (0, 5, 6, 7, 8, 9) or number in range(11, 20):
9
        word += dict_word_ends['end'][2]
10
    return word
11

12

13
def period_result(period):
14
    dict_period = {'seconds': 'секунд',
15
                   'minutes': 'минут',
16
                   'hours': 'час',
17
                   'days': 'д',
18
                   'years': '',
19
                   'century': 'век'}
20

21
    dict_ends = {'seconds': ['', 'а', 'ы'],
22
                 'minutes': ['', 'а', 'ы'],
23
                 'hours': ['ов', '', 'а'],
24
                 'days': ['ней', 'ень', 'ня'],
25
                 'years': ['лет', 'год', 'года'],
26
                 'century': ['ов', '', 'а']}
27

28
    if period // 3600 // 24 // 365 // 100 > 60000000:
29
        result = True
30
        return result
31
    if period < 60:
32
        word = dict_period['seconds']
33
    elif 60 <= period < 3600:
34
        word = dict_period['minutes']
35
        period = period // 60  # Minutes Count
36
    elif 3600 <= period < (24 * 3600):
37
        word = dict_period['hours']
38
        period = period // 3600  # Hours Count
39
    elif 24 * 3600 <= period < (24 * 3600) * 365:
40
        word = dict_period['days']
41
        period = period // 3600 // 24  # Days Count
42
    elif ((24 * 3600) * 365) <= period < ((24 * 3600) * 365 * 100):
43
        word = dict_period['years']
44
        period = period // 3600 // 24 // 365  # Years Count
45
    elif period >= ((24 * 3600) * 365 * 100):
46
        word = dict_period['century']
47
        period = period // 3600 // 24 // 365 // 100  # Centuries Count
48
    # 15
49
    if int(period) % 10 in (0, 5, 6, 7, 8, 9) or int(period) in range(11, 20):
50
        if word == dict_period['seconds']:
51
            word += dict_ends['seconds'][0]
52

53
        if word == dict_period['minutes']:
54
            word += dict_ends['minutes'][0]
55

56
        if word == dict_period['hours']:
57
            word += dict_ends['hours'][0]
58

59
        if word == dict_period['days']:
60
            word += dict_ends['days'][0]
61

62
        if word == dict_period['years']:
63
            word += dict_ends['years'][0]
64

65
        if word == dict_period['century']:
66
            word += dict_ends['century'][0]
67

68
    elif int(period) % 10 == 1 and int(period) not in range(11, 20):  # 1
69
        if word == dict_period['seconds']:
70
            word += dict_ends['seconds'][1]
71

72
        if word == dict_period['minutes']:
73
            word += dict_ends['minutes'][1]
74

75
        if word == dict_period['hours']:
76
            word += dict_ends['hours'][1]
77

78
        if word == dict_period['days']:
79
            word += dict_ends['days'][1]
80

81
        if word == dict_period['years']:
82
            word += dict_ends['years'][1]
83

84
        if word == dict_period['century']:
85
            word += dict_ends['century'][1]
86

87
    elif int(period) % 10 in (2, 3, 4):  # 4
88
        if word == dict_period['seconds']:
89
            word += dict_ends['seconds'][2]
90

91
        if word == dict_period['minutes']:
92
            word += dict_ends['minutes'][2]
93

94
        if word == dict_period['hours']:
95
            word += dict_ends['hours'][2]
96

97
        if word == dict_period['days']:
98
            word += dict_ends['days'][2]
99

100
        if word == dict_period['years']:
101
            word += dict_ends['years'][2]
102

103
        if word == dict_period['century']:
104
            word += dict_ends['century'][2]
105
    result = str(f'{period:,}') + ' ' + word
106
    return result
107

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.