개발/python

#2.6 Parameters 파라미터_8월30일

규지니어스 2022. 8. 30. 19:47

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")