728x90
    
    
  반응형
    
    
    
  11. 파이썬 클래스 / 281 ~ 290
# 파이썬 300제 _ 281번 ~ 287번
# class CAR():
#     def __init__(self, wheel, price):
#         self.wheel = wheel
#         self.price = price
#     def info(self):
#         print("바퀴수 ", self.wheel)
#         print("가격 ", self.price)
# class BICYCLE(CAR):
#     # pass
#     def __init__(self, wheel, price, ds):
#         super().__init__(wheel, price)
#         self.ds = ds
    
#     def info(self):
#         super().info()
#         print("구동계 ", self.ds)
# class CAR1(CAR):
#     def __init__(self, wheel, price):
#         super().__init__(wheel, price)
    
#     def info(self):
#         print("바퀴수 ", self.wheel)
#         print("가격 ", self.price)
# bicycle = BICYCLE(2, 100, "시마노")
# bicycle.info()
# 286번
# bicycle = BICYCLE(2, 100, "시마노")
# bicycle.info()
# 285번
# car = CAR1(4, 1000)
# car.info()
# 284번
# bicycle = BICYCLE(2, 100, "시마노")
# print(bicycle.ds)
# 283번
# bicycle = BICYCLE(2, 100)
# print(bicycle.price)
# 281번
# car = CAR(2, 1000)
# print(car.wheel)
# print(car.price)
# 288번
# class Parent():
#     def call(self):
#         print("부모호출")
# class Child(Parent):
#     def call(self):
#         print("자식호출")
# my = Child()
# my.call()
# 결과 : 자식호출
# 289번
# class Parent():
#     def __init__(self):
#         print("부모생성")
# class Child(Parent):
#     def __init__(self):
#         print("자식생성")
# my = Child()
# 결과 : 자식생성
# 290번
# class Parent():
#     def __init__(self):
#         print("부모생성")
# class Child(Parent):
#     def __init__(self):
#         print("자식생성")
#         super().__init__()
# my = Child()
# 결과 : 자식생성, 부모생성728x90
    
    
  반응형
    
    
    
  'Python' 카테고리의 다른 글
| Mac OS 아나콘다(Anaconda) 및 파이참(PyCharm) 설치, 설정 (0) | 2020.11.25 | 
|---|---|
| 초보자를 위한 파이썬 300제 / 11. 파이썬 클래스 / 271 ~ 280 (0) | 2020.09.22 | 
| 초보자를 위한 파이썬 300제 / 11. 파이썬 클래스 / 261 ~ 270 (0) | 2020.09.22 | 
| 초보자를 위한 파이썬 300제 / 11. 파이썬 클래스 / 251 ~ 260 (0) | 2020.09.16 | 
| 초보자를 위한 파이썬 300제 / 10. 파이썬 모듈 / 241 ~ 250 (0) | 2020.09.14 |