Language/Python

데이터 타입

원2 2021. 6. 25. 10:08
728x90
반응형

# 숫자 (int, float)

# 타입을 리턴하는 함수
print( type(1) )
print( type(1.123) )

print( type(2+4) )
print( type(2-4) )
print( type(2*4) )
print( type(2/4) ) # 자동 형변환
print( type(9.9+1.1) ) # 11.0 자동 형변환 X

print("-------------")

# 거듭제곱  >>  **
print(2**3)
print(2**4)
print(2**5)
print(2**6)
print("-------------")

# 나누기의 몫
print(5//4)
print("-------------")

# 나누기의 나머지 %
print(11%4)
print("-------------")

# 반올림 함수
print(round(4.1234))
print("-------------")

# 절대값 함수
print(abs(-20))
print("-------------")

# 이진수 변환 bin()
print(bin(5))
print(int("0b101",2))
print("-------------")
728x90
반응형

'Language > Python' 카테고리의 다른 글

예제 01-10  (0) 2021.06.30
module, random, max, password  (0) 2021.06.28
while 문, for 문  (0) 2021.06.28
if, elif, else  (0) 2021.06.25
내장함수 function  (0) 2021.06.25
Python 문자열 str, format ,index  (0) 2021.06.25