kmb266 / cs5150-basketball-project

A basketball stats program created by a CS 5150 team during the Spring 2018 semester
0 stars 0 forks source link

Float? #4

Closed dbr96 closed 6 years ago

dbr96 commented 6 years ago

https://github.com/kmb266/cs5150-basketball-project/blob/37a68d206d91ba7208e61c851fe2e65c8e60493b/app/advanced_stat.py#L135

Noticed this one doesn't have 'float' before the formula. Does that matter? What does float mean?

kmb266 commented 6 years ago

Float means a number has a decimal. (example 4.5 or 4.0) where as a whole number is called an integer or int. (example: 4 or 25) If there is number in the formula that has a decimal, it automatically makes all the other numbers floats. So because .5 is in the formula, then all the integers, 2, 1, FGA, etc are converted to 2.0, 1.0, and whatever FGA is with .0 at the end.

This matters in python because if you try and divide just integers it will only give you an integer as the answer, even if it should be a float. Example 16/10 = 1 in python where as 16.0/10 = 1.6.