파이썬에서 함수를 정의할 때 사용하는 def는 "정의하다"라는 의미를 가진 영단어 define에서 나온 것입니다!
또한 프로그래밍에서 함수를 의미하는 function은 "기능 / 작동(기능)하다"라는 뜻을 가진 영단어입니다.
함수는 호출될 때만 실행되는 코드 블록입니다.
매개변수라고 하는 데이터를 함수에 전달할 수 있습니다.
함수는 결과로 데이터를 반환할 수 있습니다.
https://www.w3schools.com/python/python_functions.asp
W3Schools.com
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
www.w3schools.com
# Python에서는 def 키워드를 사용하여 함수를 정의합니다.
def my_function():
print("Hello from a function")
# 함수를 호출하려면 함수 이름 뒤에 괄호를 사용하세요.
my_function()
반응형
'CODING > Python' 카테고리의 다른 글
5. Parameters (0) | 2025.10.16 |
---|---|
4. Indentation (0) | 2025.10.16 |
7. Default Parameters (0) | 2025.10.16 |
6. Multiple Parameters (0) | 2025.10.16 |
2. Booleans and Strings (0) | 2025.10.16 |