Answers for "in python percent"

1

how to get percentage in python

def percentage(part, whole):
  return 100 * float(part)/float(whole)

print(percentage(5, 7))
# If you want to limit the number of decimal to 2, change the number in {:.2f} as you wish;
print('{:.2f}'.format(percentage(5, 7)))
Posted by: Guest on July-29-2021

Python Answers by Framework

Browse Popular Code Answers by Language