📝 개념 정리
= : 지정 연산자return : 입력값을 받아 어떤 처리를 한 후에 결괏값을 돌려줌// : 버림 나눗셈, floor divisionround : 반올림def hello(name): #name : 파라미터 명. 함수 내에서 문자열 출력 가능
print("Hello!")
print(name)
print("world!")
hello("조민지")
결과 :
Hello!
조민지
world!
곱셈
def abc(a,b,c):
print(a*b*c)
abc(7, 3, 5)
abc(21, 4, 9)
abc(-7, 6, 3)
def get(x):
return x * x #반환되는 return문
y = get(3) #y의 값은 return x * x. 즉, 9
print(y)
def get(x):
return x * x
print(get(3) + get(4)) #각각의 get 값은 9와 16이 된다
# 출력값 : 25
def my_function(x, y):
return x + x + y
print(my_function(10, 20)) #x=10, y=20
#출력값 : 40
//
print (7//2) # // : floor division (버림 나눗셈)
#결과 3 : 소수 부분 제외
print (8.0//3) #2.0 : 둘 중 하나가 소수면 값도 소수형
print(round(3.1415926535)) # round : 반올림 /값 : 3
print(round(3.1415926535, 2)) # 소수 두번째 자리까지
# 반올림. 값 : 3.14