Built in Function

- 기본적으로 Python에서 제공하는 함수

- print(), len(), int(), str(), ...

 

Custom Function

- 파이썬에서 함수를 정의할 때에는 def를 사용한다.

- 주의할 점은 def는 정확히는 함수를 만드는 것이 아니다. 따라서 {} 로 구분하는 것이 아니라 들여쓰기(Tab 또는 Space) 를 통해 함수의 내용을 구성한다.

def hello():
  print("hello, world!")
  print("bye bye")

hello()

 

Function Argument

- 인자의 이름과 함께 표기할 수 있다.

- print(f"{변수명}") 을 하면 변수값을 간단하게 출력할 수 있다.

def hello(who, age):
  print(f"my name is {who} and i'm {age}years old")
  print("bye bye")

hello(age=20, who="sion")

 

'앱 개발자 역량 > Python' 카테고리의 다른 글

Python GUI 비교 및 용도 선정 방법  (0) 2023.06.12
JSON Parsing 간단하게 끝내기  (0) 2021.01.19
Python ] #5 Tuple, Dictionary  (0) 2019.11.13
Python ] #4 List, Document 확인방법  (0) 2019.11.12
Python ] #3 Variable  (0) 2019.11.12

+ Recent posts