Python 몫 연산자 //

(파이썬 //에서 넘어옴)

1 개요[ | ]

Pyton Floor Division Operator //
Python 몫 연산자 //
print( 5 // 2 )
# 2
print( 5 // 2.0 )
# 2.0
print( 5.0 // 2 )
# 2.0
print( 5.0 // 2.0 )
# 2.0
print( -5 // 2 )
# -3
print( -5 // 2.0 )
# -3.0
print( -5.0 // 2 )
# -3.0
print( -5.0 // 2.0 )
# -3.0
import math
print( math.floor( 5 / 2 ) )
# 2
print( math.floor( 5.0 / 2.0 ) )
# 2
print( math.floor( -5 / 2 ) )
# -3
print( math.floor( -5.0 / 2.0 ) )
# -3

2 같이 보기[ | ]

3 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}