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)))

Here is what the above code is Doing:
1. We created a function called percentage that takes two arguments: part and whole.
2. We return the percentage of the part to the whole.
3. We print the percentage of 5 to 7.
4. We print the percentage of 5 to 7 with 2 decimal places.