변수와 타입

Python 입문

Hugo Bowne-Anderson

Data Scientist at DataCamp

변수

  • 구체적이고 대소문자를 구분하는 이름

  • 변수 이름을 통해 값을 호출

  • 1.79 m - 68.7 kg

height = 1.79
weight = 68.7

height
1.79
Python 입문

BMI 계산하기

height = 1.79
weight = 68.7

height
1.79

$$ {{1}}extBMI = racextweightextheight^2 $$

68.7 / 1.79 ** 2
21.4413
weight / height ** 2
21.4413
bmi = weight / height ** 2
bmi
21.4413
Python 입문

재현성

height = 1.79
weight = 68.7
bmi = weight / height ** 2
print(bmi)
21.4413
Python 입문

재현성

height = 1.79
weight = 74.2 # <-
bmi = weight / height ** 2
print(bmi)
23.1578
Python 입문

Python 타입

type(bmi)
float
day_of_week = 5
type(day_of_week)
int
Python 입문

Python 타입(2)

x = "body mass index"
y = 'this works too'

type(y)
str
z = True
type(z)
bool
Python 입문

Python 타입(3)

2 + 3
5
'ab' + 'cd'
'abcd'
  • 다른 타입 = 다른 동작!
Python 입문

연습해봅시다!

Python 입문

Preparing Video For Download...