In [26]:
class student():
def __init__(self, name):
self.name = name
def study(self):
print("normal people study the coding")
def coding(self):
print("only special people can do the python")
# class DataScienceStudent():
# def __init__(self, name):
# self.name = name
# def study(self):
# print("normal people start study")
# def coding(self):
# print("they start study about datascience")
class DataScienceStudent(student):
def coding(self):
print ("데사스는 jupyter notebook으로 개발합니다")
In [29]:
student = student("jy")
In [12]:
student.study()
student.coding()
In [34]:
dss = DataScienceStudent("je")
In [35]:
dss.coding()
In [38]:
class student():
def __init__(self, name):
self.name = name
def introduce():
print("저는 {name}입니다".format(name = name))
class DSStudent(student):
def introduce(self):
print("안녕하세요, 저는 데사스{name}".format(name = self.name))
In [85]:
import time
class Timer():
def __init__(self, function):
self.function = function
def __call__(self, *args, **kwargs):
start_time = time.time()
result = self.function(*args, **kwargs)
end_time = time.time()
print("{time}s".format(time = end_time - start_time))
return result
In [86]:
@Timer
def print_hello(name):
print("hellow world " + name)
In [87]:
print_hello("jy")
In [ ]:
In [101]:
class FastcampusPerson():
def __init__(self, name, is_manager = False):
self.name = name
self.is_manager = is_manager
def __str__(self):
return self.name
JE = FastcampusPerson("박지은", is_manager = True)
JY = FastcampusPerson("박지용")
JE.is_manager
JY.is_manager
Out[101]:
In [127]:
class FastcampusSchool():
def __init__(self,name):
self.name = name
#student_list = []
def add_student(self, manager, student):
if manager.is_manager:
print("{manager}이 {student}를 추가했습니다".format(
manager = manager.name,
student = student.name,
))
else:
print("학생은초대가 불가합니다")
def __str__(self):
return self.name
In [128]:
DSS = FastcampusSchool("데이터 사이언스 school")
print(DSS)
In [129]:
JY = FastcampusPerson("박지용")
JE = FastcampusPerson("박지은", is_manager = True)
In [130]:
DSS.add_student(JY, JE)
In [131]:
DSS.add_student(JE, JY)
In [ ]:
class PermissionDeniedError(exception):
def __init__(self, person):
self.person = person
def __str__(self):
return("{name}은 매니저가 아니라서, 권한이 없습니다".format(name = self.person.name))