DEV/python
자료형과 추상화(Data Type_Abstruction)_개념
purple
2021. 10. 19. 23:07
'''
자료형(Data Type)
숫자
정수(Integer) ex) 1 2
소수(Floating Point) ex) 1.8 2.0
문자형(String) ex)"2" "hello"
불린(Boolean) : 논리형 True / False ex) 7>3 = True
추상화(Abstraction) : 복잡한 내용을 숨기고 주요 기능만 보이는 것
변수 (Variable) : 값을 저장
함수 (Function) : 명령을 저장
객체 (Object)
'''
#변수
burger_price = 4990
fries_price = 1490
drink_price = 1250
print(burger_price)
print(burger_price*2)
print(burger_price+fries_price)
print(burger_price*3+fries_price*3+drink_price*5)
#함수
def hello(name): # 함수의 첫 줄을 헤더라고 합니다. 파라미터를 받을 수도 있다
print("""Hello!
welcom to Codeit!""")
print(name)
hello("chris")
hello(2)
def print_sum(a, b, c):
print(a+b+c)
print_sum(7,3,2)
#return : 함수의 핵심개념, 정보를 받을 시 어떤 정보를 돌려준다.
def get_square(x):
return x*x
y = get_square(3)
print(y)
print(get_square(5)+get_square(2))
결과
4990
9980
6480
25690
Hello!
welcom to Codeit!
chris
Hello!
welcom to Codeit!
2
12
9
29