1
+ from random import random , uniform
1
2
from typing import Iterable
2
3
3
4
UNCULTURED_WORDS = ('kotleta' , 'pirog' )
@@ -12,7 +13,8 @@ def greet_user(name: str) -> str:
12
13
:return: приветствие
13
14
"""
14
15
15
- # пиши код здесь
16
+ greeting = "Hi, " + name + "!"
17
+
16
18
return greeting
17
19
18
20
@@ -28,7 +30,8 @@ def get_amount() -> float:
28
30
:return: случайную сумму на счете
29
31
"""
30
32
31
- # пиши код здесь
33
+ amount = round (uniform (100 , 1000000 ), 2 )
34
+
32
35
return amount
33
36
34
37
@@ -42,7 +45,15 @@ def is_phone_correct(phone_number: str) -> bool:
42
45
False - если номер некорректный
43
46
"""
44
47
45
- # пиши код здесь
48
+ if (phone_number [0 ] != '+' or phone_number [1 ] != '7' ):
49
+ return False
50
+
51
+ result = True
52
+ for i in range (2 , len (phone_number )):
53
+ if (phone_number [i ] < '0' or '9' < phone_number [i ]):
54
+ result = False
55
+ break
56
+
46
57
return result
47
58
48
59
@@ -58,8 +69,9 @@ def is_amount_correct(current_amount: float, transfer_amount: str) -> bool:
58
69
False - если денег недостаточно
59
70
"""
60
71
61
- # пиши код здесь
62
- return result
72
+ if (current_amount < float (transfer_amount )):
73
+ return False
74
+ return True
63
75
64
76
65
77
def moderate_text (text : str , uncultured_words : Iterable [str ]) -> str :
@@ -77,7 +89,17 @@ def moderate_text(text: str, uncultured_words: Iterable[str]) -> str:
77
89
:return: текст, соответсвующий правилам
78
90
"""
79
91
80
- # пиши код здесь
92
+ result = text .strip (" " )
93
+ result = result .lower ()
94
+ result = result .capitalize ()
95
+ result = result .replace ('\' ' , "" )
96
+ result = result .replace ("\" " , "" )
97
+ for i in UNCULTURED_WORDS :
98
+ if i in result :
99
+ result = result .replace (i , "#" * len (i ))
100
+
101
+ return result
102
+
81
103
return result
82
104
83
105
@@ -100,5 +122,7 @@ def create_request_for_loan(user_info: str) -> str:
100
122
:return: текст кредитной заявки
101
123
"""
102
124
103
- # пиши код здесь
125
+ info = user_info .split ("," )
126
+ result = f"Фамилия: { info [0 ]} \n Имя: { info [1 ]} \n Отчество: { info [2 ]} \n Дата рождения: { info [3 ]} \n Запрошенная сумма: { info [4 ]} "
127
+
104
128
return result
0 commit comments