This language bar is your friend. Select your favorite languages!
Edit summary for version 26 :
[Python] Variable name s

Version 25

Version 26

Idiom #65 Format decimal number

From real value x in [0,1], create its percentage string representation s with one digit after decimal point. E.g. 0.15625 -> "15.6%"

Idiom #65 Format decimal number

From real value x in [0,1], create its percentage string representation s with one digit after decimal point. E.g. 0.15625 -> "15.6%"

Extra Keywords
percent
Extra Keywords
percent
Code
'{:.1%}'.format(x)
Code
s = '{:.1%}'.format(x)
Comments bubble
``.1`` means only one digit after decimal point.
``%`` handels the "multiplication" and shows the percentage sign.
Comments bubble
.1 means only one digit after decimal point.
% handles the "multiplication" and shows the percentage sign.
Doc URL
https://docs.python.org/3/library/string.html#formatstrings
Doc URL
https://docs.python.org/3/library/string.html#formatstrings