728x90
test1
from future.backports.xmlrpc.client import boolean
class Animal:
# print("생성자")
def __init__(self):
self.flag_sound = True
#메소드
def bbeonguri(self):
self.flag_sound = False
# 메모리에서 사라질떄 호출됨
def __dal__(self):
# print("소멸자")
pass
# toSting과 같음
def __str__(self):
return "소리능력" + str(self.flag_sound)
# if __name__ == '__main__':
# a = Animal()
# print(a.flag_sound)
# a.bbeonguri()
# print(a.flag_sound)
#
class Human(Animal):
def __init__(self):
super().__init__()
self.community_skill = 0
def momstouch(self,punch):
self.community_skill += punch
if __name__ == '__main__':
a=Human()
print(a.community_skill)
print(a.flag_sound)
a.bbeonguri()
a.momstouch(10)
print(a.community_skill)
print(a.flag_sound)
test2
from day03.myoop01 import Animal
a = Animal()
print(a.flag_sound)
a.bbeonguri()
print(a.flag_sound)
test3
class Vehicle:
def __init__(self):
self.wheel_cnt=2
def flex(self):
self.wheel_cnt=4
def __dal__(self):
pass
class Car(Vehicle):
def __init__(self):
super().__init__()
self.autopilot_level= 1
def hit(self):
self.autopilot_level += 1
if __name__ == '__main__':
a= Car()
print(a.wheel_cnt)
print(a.autopilot_level)
a.flex()
a.hit()
a.hit()
a.hit()
a.hit()
print(a.wheel_cnt)
print(a.autopilot_level)
test4
class BIden:
def __init__(self):
self.head_color="white"
def dye(self):
self.head_color="red"
class LeeJY:
def __init__(self):
self. cnt_company = 10
def hit(self,punch):
self.cnt_company += punch
class Musk:
def __init__(self):
self.cnt_sat = 1000
def launch(self):
self.cnt_sat += 10
class Eunbi(BIden,LeeJY,Musk):
def __init__(self):
BIden.__init__(self)
LeeJY.__init__(self)
Musk.__init__(self)
if __name__ == '__main__':
e = Eunbi()
print(e.head_color)
e.dye()
print(e.head_color)
print(e.cnt_company)
e.hit(10)
print(e.cnt_company)
print(e.cnt_sat)
e.launch()
print(e.cnt_sat)
'Python > Python 기초' 카테고리의 다른 글
파이썬(String) 문자열 문법정리 (0) | 2023.06.25 |
---|---|
파이썬 가위바위보 인공지능 프로그램 만들기 (0) | 2023.06.24 |
파이썬 기초Test(테스트) (0) | 2023.06.23 |
파이썬 함수(function) def예제 (0) | 2023.06.23 |
파이썬 1일차 테스트 (0) | 2023.06.21 |