본문 바로가기

프로그래밍

[python] 변수 사용법

변수 선언

a = 10

b = 20

c = '한글'

a, b, c = 10, 20, 30

a = b = c = 15

 

변수 자료형 int, string, float, bool, None

a = 10

b = '한글'

c = 10.1

d = True

e = None

print(type(a))

print(type(b))

print(type(c))

print(type(d))

print(type(e))

 

결과

<type 'int'>
<type 'str'>
<type 'float'>
<type 'bool'>
<type 'NoneType'>

 

설명

int : 정수

str : 문자열

float : 실수 (소수점)

bool : True(1) , False(0) (첫글자 대문자)

None : 값이 없을때 (java의 null과 비슷한 의미)