본문 바로가기

Python

Python [function] argugment use

<function 인자값 받아서 출력>

 

def say_hi(who):

  print("hi!!", who)

 

say_hi("kim") => hi!! kim

 

 

<예시>

 

def plus(a, b):

  print(a + b)

 

def minus(a, b):

  print(a - b)

 

plus(2, 1) => 3

minus(2, 1) => 1

 

 

<fnc arg default value , 함수 인자값 디폴트 지정>

 

def plus(a, b=3):     <- b=3 처럼 해당 인자에 디폴트 값 지정 할 수 있다.

  print(a + b)

 

plus(2) => 5

 

'Python' 카테고리의 다른 글

Python [function] arg 위치 지정 호출  (0) 2019.11.24
Python [function] return , void 차이  (0) 2019.11.24
Python function def , use  (0) 2019.11.24
Python Dictionary type (javascript obj 같은 것)  (0) 2019.11.24
Python tuple [Sequence Type]  (0) 2019.11.23