How to use 'how to find percentage in python' in Python

Every line of 'how to find percentage in python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
172def get_percentage(i, n):
173 if n == 0:
174 return '0 %'
175 else:
176 v = 100 * (1.0 * i / n)
177 return '%.1f %%' % v
93def percent(numerator, denominator):
94 """
95 :param numerator: float
96 Numerator of fraction
97 :param denominator: float
98 Denominator of fraction
99 :return: str
100 Fraction as percentage
101 """
102
103 if denominator == 0:
104 out = "0"
105 else:
106 out = str(int(numerator / float(denominator) * 100))
107
108 return out + "%"

Related snippets