Skip to content

Instantly share code, notes, and snippets.

@nattybear
Last active March 9, 2021 05:24
Show Gist options
  • Save nattybear/8c974ee1cdb3697a0f296ee47b561d92 to your computer and use it in GitHub Desktop.
Save nattybear/8c974ee1cdb3697a0f296ee47b561d92 to your computer and use it in GitHub Desktop.
파이썬 함수

함수

함수는 어떤 값을 넣으면 어떤 값이 나오는 것입니다.

아래 코드에서 f는 어떤 숫자를 넣으면 그 수에 1을 더한 값이 나오는 함수입니다.

def f(x):
  return x + 1

y = f(1)

print(y)  # 2

함수를 사용할 때는 함수 이름을 적고 다음에 괄호를 적은 다음 괄호 안에 넣고 싶은 값을 넣어 사용합니다.

함수를 이용하면 반복되는 코드를 재사용 할 수 있습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment