How to calculate Value in (%) and than create new column with percentage of used time. (Python)
Terry Reedy
tjreedy at udel.edu
Sat Jun 17 13:21:48 EDT 2017
On 6/17/2017 1:04 AM, mcmxl at hotmail.com wrote:
> I assigned the optimal time of 960min to x.
>>>> x=960.0
>
> Then I assigned the time used 189min to y.
>>>> y=189.0
>
> Then I divide the time used(y) by the optimal time(x) and multiply the answer by 100 and assign the answer to z.
>>>> z=(y/x)*100
>
> The answer.
>>>> z
> 19.6875
>
> For Python to give you an accurate answer you must include decimal points.
> I hope this helps.
In Python 3, they do not matter here.
>>> (189/960)*100
19.6875
In 2.7:
>>> (189/960)*100
0
>>> from __future__ import division
>>> (189/960)*100
19.6875
--
Terry Jan Reedy
More information about the Python-list
mailing list