Steve Holden wrote: > Sen-Lung Chen wrote: > >>Dear All: >> I have a question of show percentage. >>For example ,I want to show the percentage of 1/3 = 33.33% >> >> I use the 1*100/3 = 33 >>it is 33 not 33.33 , how to show the 33.33 % >> Thanks >> > > You should by now know enough answers. The easiest way to ensure that > the result is floating point is to cast it as > > pct = 100.0 * v) / N > > This is guaranteed to work in all past and future Python versions > without setting any options. Then you can format is using the % operator. > > regards > Steve ... apart from the obvious syntax error, that is. Sigh. pct = (100.0 * v) / N regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.pycon.org
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4