앱 개발자 역량/Python
Python ] #6 Function
it_블로거
2019. 11. 13. 14:56
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")