float is OK, int gives wrong output python 2.7 [duplicate]
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: Why doesn’t this division work in python? I have this and works fine def roi(stake, profit): your_roi = profit / stake * 100 return your_roi def final_roi(): roi1 = roi(52, 7.5) print "%.2f" % roi1 final_roi() but if I change the profit number to an int (meaning both stake and profit will have an int value) e.g. 52, 7 it is giving the output of 0.00. what's wrong there? I thought it had been formatted to be a