목록python function (1)
오식랜드
[python] 함수
함수 선언 def 함수이름 () : def 함수이름(): 실행 명령문1 실행 명령문2 .... 함수 사용 def greeting(): print('hi') greeting() # 함수 호출 함수 반환과 파라미터 소괄호() 안에 파라미터 전달 가능 return 을 통해 값 반환도 가능 def greeting(text): return print(text) greeting('bye') # bye 출력 또한 파라미터에는 기본값을 넣어줄 수 있습니다 def greeting(text='hello'): return print(text) greeting() # hello 출력 가변인자 좋아하는 과일 이름을 파라미터로 놓고 출력하는 함수를 만들었다 def fruit(fruit1, fruit2, fruit3, fruit4..
dev-log/python
2023. 1. 9. 14:43