-
Notifications
You must be signed in to change notification settings - Fork 470
Expand file tree
/
Copy path7_exception2.py
More file actions
28 lines (22 loc) · 1.05 KB
/
7_exception2.py
File metadata and controls
28 lines (22 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""
Домашнее задание №1
Исключения: приведение типов
* Перепишите функцию discounted(price, discount, max_discount=20)
из урока про функции так, чтобы она перехватывала исключения,
когда переданы некорректные аргументы.
* Первые два нужно приводить к вещественному числу при помощи float(),
а третий - к целому при помощи int() и перехватывать исключения
ValueError и TypeError, если приведение типов не сработало.
"""
def discounted(price, discount, max_discount=20)
"""
Замените pass на ваш код
"""
pass
if __name__ == "__main__":
print(discounted(100, 2))
print(discounted(100, "3"))
print(discounted("100", "4.5"))
print(discounted("five", 5))
print(discounted("сто", "десять"))
print(discounted(100.0, 5, "10"))