def say_hello():
print("hello how r u?")
-> 출력물 바꾸기
hello 사람이름 how r u?
say_hello("nico")
를 쓰면 에러가 뜬다.
왜냐하면
def say_hello():
print("hello how r u?")
는 데이터를 받을 준비가 되어있지않다.
(값을 받을 공간을 가지고 있지 않다.)
def say_hello(user_name):
print("hello", user_name, "how r u?")
say_hello("nico")
console >>
hello nico how r u?
=>
여기서
(user_name)은 파라미터(parameter)
say_hello("nico")
전달한 nico는 argument 이다.
* 보통 혼용해서 쓰기에..
function이 데이터를 주고받는 게 중요한 거다.
function안에서만 유효하다
def say_bye():
print("bye bye")
'개발 > python' 카테고리의 다른 글
#2.9 Default Parameters 기본 파라미터_9월3일 (0) | 2022.09.03 |
---|---|
#2.7 Multiple Parameters 다중 매개변수_9월1일 (0) | 2022.09.01 |
#2.5 Indentation 들여 쓰기_8월29일 (0) | 2022.08.29 |
#2.4 Function 함수_8월 28일 (1) | 2022.08.28 |
#2.3 Recap (0) | 2022.08.27 |