반응형
방법 #1
def lesser(a,b):
if a%2==0 and b%2==0:
if a<b:
result=a
else:
result=b
else:
if a>b:
result=a
else:
result=b
return result
방법 #2
def lesser(a,b):
if a%2==0 and b%2==0:
result=min(a, b)
else:
result=max(a, b)
return result
result를 생략해도 됩니다.
def lesser(a,b):
if a%2==0 and b%2==0:
return min(a, b)
else:
return max(a, b)
반응형
'Python > PYTHON NumPy & Pandas' 카테고리의 다른 글
[pandas] 보여주는 데이터 열 개수 변경하기; pd.options.display.min (0) | 2022.07.05 |
---|---|
[pandas] 행, 열 합(sum) 구하기 (0) | 2020.09.04 |
[pandas] 데이터프레임 속성 확인 명령어들 (0) | 2020.08.31 |
[function연습] 두 단어의 앞글자가 같으면 true, 아니면 false (0) | 2020.05.18 |
Python numpy/pandas library 들어가기에 앞서 (0) | 2020.05.05 |