Division in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Division in python

Hi can anyone help with a formula for division for example traveling an aero plane travels 5000 kilometers on 300 liters of fuel how many kilometers per liter? 5000 / 300 would like to use float or integer?

2nd Feb 2018, 7:04 AM
Gerald
Gerald - avatar
2 Answers
+ 11
for java , u should use double or float type bcz integer/integer gives an integer value only ie 5000/300 will be 18 in java 5000.0/300.0 will be 18.6666666666.....
2nd Feb 2018, 8:11 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 1
This will depend greatly on the language you're using, and will need to use a float type variable to hold the result (unless you're okay with some data loss, or want to round it).
2nd Feb 2018, 7:24 AM
Tom Shaver
Tom Shaver - avatar