BMI calculator always return 0. (Python)
Question: i was just writing this very simple script to calculate bmi in kg and cm. But
it always prints 0. Any ideas why?

code:

    
    
    weight = int(raw_input("Weight in kg: "))
    length = int(raw_input("Length in cm: "))
    
    def bmi():
        bmi = (weight) / (length * length)
        return bmi
    
    print bmi()
    


Answer: Type cast it to `float`. `/` will do integer division always.

That is

    
    
    bmi = float(weight) / float(length * length)
    

It will print

    
    
    Weight in kg: 10
    Length in cm: 20
    0.025
    

Or do

    
    
    from __future__ import division
    

