Ответ:
try:
result = 10 / 0
except ZeroDivisionError:
print("ZeroDivisionError")
content = open("несуществующий_файл.txt").read()
except FileNotFoundError:
print("FileNotFoundError")
value = int("abc")
except ValueError:
print("ValueError")
print({"key": "value"}["nonexistent_key"])
except KeyError:
print("KeyError")
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Verified answer
Ответ:
try:
result = 10 / 0
except ZeroDivisionError:
print("ZeroDivisionError")
try:
content = open("несуществующий_файл.txt").read()
except FileNotFoundError:
print("FileNotFoundError")
try:
value = int("abc")
except ValueError:
print("ValueError")
try:
print({"key": "value"}["nonexistent_key"])
except KeyError:
print("KeyError")