forked from ElvinKim/2018_1_ITA_python_class_C
-
Notifications
You must be signed in to change notification settings - Fork 0
/
20180130_3.py
60 lines (46 loc) · 1.29 KB
/
20180130_3.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""
예외처리
"""
import random as rd
# print("{:-^20}".format(" Sample "))
# while True:
# try:
# a = int(input("a = "))
# b = int(input("b = "))
# print("{} / {} = {}".format(a, b, a / b))
# except ZeroDivisionError as e:
# print(e)
# print("0으로 나눌 수 없어!!!")
# except ValueError as e:
# print(e)
# print("입력 값에 문제가 있네....!")
# except Exception as e:
# print(e)
print("{:-^20}".format(" 오류 발생 시키기 "))
class Person:
def introduce(self):
raise NotImplemented
class Police(Person):
def introduce(self):
print("나는 경찰관이야!!!")
class Student(Person):
def introduce(self):
print("나는 학생이야~~~")
kim = Police()
kim.introduce()
park = Student()
park.introduce()
print("{:-^20}".format(" 에러만들기 "))
class Molla(Exception):
def __str__(self):
return "몰라 에러 발생이야."
class ScoreError(Exception):
def __str__(self):
return "범위가 아닌 값을 입력하였습니다."
def input_score(score):
if score < 0 or score > 100:
raise ScoreError()
try:
input_score(200)
except ScoreError as e:
print(e)