Python

04 - 숫자(number)

CMS419 2020. 7. 7. 09:53

숫자(number)

 

정수(integer) : 음의 정수, 양의 정수, 0

- 10진수, 2진수, 8진수, 16진수

ex) '100'이라는 수를 다양한 진수로 변할 수 있다.

100(10진수), 0x6A(16진수), 0o144(8진수), 0b1100100(2진수)

 

자연수(numeric) : 1,2,3,4,.....

실수(float) : 소수점은 가진 수

 - 유리수 : 끝이 있는 수 ex) 10.21

 - 무리수 : 끝없는 수(inf) ex) 3.141529....

 

type함수로 객체의 자료형 알아내기

 

print(type(10)) #class int
print(type(10.5)) #class float
print(type(float("inf"))) #class float