Implement a function called get_percentage() that converts a real number to a percentage string.
The function should:
Take two parameters:
A required real number to be converted to a percentage
An optional
round_digitsparameter for specifying precision (default should round to the nearest integer)
Return a string representing the percentage, including the '%' symbol
Use the built-in
round()function for precision control. The function takes up to two arguments,numberandndigits.
Function behavior:
If
round_digitsis not specified, round to the nearest integerIf
round_digitsis specified, round to that many decimal placesAlways append '%' to the result
Examples (# indicates a comment and is not a part of the result string):
print(get_percentage(0.0123)) # 1%
print(get_percentage(0.0123, 0)) # 1.0%
print(get_percentage(0.0123, 1)) # 1.2%
print(get_percentage(0.0123, 10)) # 1.23%
print(get_percentage(0.0296, 1)) # 3.0%Just implement the function, you don't have to handle input or call it in your code.