float(float(1)/float(i) * float(score))
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming Python 2.x:
1.0 / i * scoreThe main case you need to worry about is the division because in Python 2.x, division is defaulted to integer division. In order to have floating-point division, either the dividend or divisor needs to be a float, hence the
1.0. Thus,1.0/iwill be a float, and multiplying a float by score (which can either be an integer or float) will result in another floating-point number.In python 3.x, however, division defaults to floating-point division, so
1 / i * scorewould work.