본문 바로가기

PROGRAM/Python

class -sample

 

class Man:
    def __init__(self, name):
        self.name = name
        print("초기화됨")
    def hello(self):
        print("Hello "+self.name+"!")
    def goodbye(self):
        print("Goodbye "+self.name+"!")

m = Man("David")
m.hello()
m.goodbye()

초기화됨

Hello David!

Goodbye David!

'PROGRAM > Python' 카테고리의 다른 글

랜덤뽑기  (0) 2022.09.01
Class / lambda식 등  (0) 2020.09.07
iris.csv 분석  (0) 2020.07.31
jupyter notebook을 tistory에 적용하기  (0) 2020.07.30
Turtle - Example  (0) 2020.04.27