Divided by int or by float : Divide « Language Basics « Python






Divided by int or by float

Divided by int or by float

from __future__ import division

print (5 / 2), (5 / 2.0), (5 / -2.0), (5 / -2)

print (5 // 2), (5 // 2.0), (5 // -2.0), (5 // -2)

print (9 / 3), (9.0 / 3), (9 // 3), (9 // 3.0)


           
       








Related examples in the same category

1.truncating divisiontruncating division
2.Read a number and do the divide by 2Read a number and do the divide by 2
3.Divide in PythonDivide in Python