220629

Grace Goh·2022년 6월 29일
0

개발일지5

목록 보기
1/2

indent를 잘 지켜야 한다.

다음과 같이 클래스 내 함수를 만든다.

class Monster():
    hp = 100
    mp = 10

    def damage(self, attack):
        self.hp = self.hp - attack

monster1 = Monster()
monster1.damage(120)

monster2 = Monster()
monster2.damage(90)

다음과 같이 함수를 사용할 수 있다.
객체명.함수명(인자)

monster1.damage(100)

try 부분을 시도하고, 에러가 발생할 것 같으면 에러 대신에 except 부분을 수행한다.

try:
	print(a/b)
except:
	print('0으로는 나눌 수 없어요!')

파이썬 상단에서 한 번만 불러오면(import) 된다.

import pandas as pd

pd.함수이름
의 형태로 사용할 수 있다.

데이터프레임
https://colab.research.google.com/drive/1il3hoEFKF8bECDXgLHSXFEoO45PIrO6b?hl=ko#scrollTo=tALiEZKOCFBv

Keep
Problem
Try

profile
Español, Inglés, Coreano y Python

0개의 댓글