무기체계와 컴퓨터/프로그램 언어

함수 Function

xdots 2023. 10. 21. 10:16

함수 특징

  • 식별자 뒤에 괄호가 붙어 있으면, 해당 식별자를 함수하고 부른다
  • 함수를 호출한다_함수를 사용하는 것
  • (매개변수) 함수 호출 시 함수에 정보를 전달하기 위해 사용하는 변수
  • (리턴값) 함수를 호출한 최종적인 결과, 함수가 실행을 종료하면 처리한 값을 반환할때 사용
  • A function is a block of code that performs a specific task when the function is called (invoked). You can use functions to make your code reusable, better organized, and more readable. Functions can have parameters and return values.

Types of functions

  • built-in functions
  • pre-installed modules
  • user-defined functions
#매개변수 name이 있는 outputName 함수를 이용하는 프로그램
def outputName(name):
    print('이름은', name, '입니다')

name=input('이름: ')
outputName(name)