#파이썬 함수 : 특정 기능을 실행하는 코드 또는 코드의 모임

#내장 함수
'''
print() 출력 함수
input() 입력 함수
len() 시퀀스 자료의 길이를 나타내는 함수
sum() 시퀀스 자료의 합을 알려주는 함수
max() 최댓값
min() 최솟값
str() 문자열로 변환하는 함수

함수 vs 메서드
메서드 : 함수인데 특정 자료만 사용할 수 있게 만든 전용 함수
'''

#사용자 정의 함수
def hello():
    print('안녕하세요')

hello()
hello()

def add(a, b):
    print(a + b)

add(10, 5)
add(5, 8)

def name(x):
    print(f'이름은 {x}입니다')
    return x
    
name('주현')
y = name('민지')
print(y)

def mul(a, b, c):
    x = a * b
    y = b * c
    return x, y

print(mul(1, 2 ,3))


print('----문제1----')
def greet(name, age):
    print(f'이름은 {name}이고, 나이는 {age}입니다')

greet('주현', 14)


print('----문제2----')
def clac(a, b):
    A = a + b
    B = a * b
    print(A, B)
    return A, B

print(clac(7, 2))


#기본값이 있는 인자
def greet2(name = '홍길동'):
    print('이름은',name)

greet2()
greet2('박주현')






Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: