mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
Create percentageFunc.py
This commit is contained in:
10
mathgenerator/funcs/percentageFunc.py
Normal file
10
mathgenerator/funcs/percentageFunc.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from .__init__ import *
|
||||||
|
|
||||||
|
def percentageFunc(maxValue = 99, maxpercentage=99):
|
||||||
|
a = random.randint(1, maxpercentage)
|
||||||
|
b = random.randint(1, maxValue)
|
||||||
|
problem = f"What is {a}% of {b}?"
|
||||||
|
percentage = a/100*b
|
||||||
|
formatted_float = "{:.2f}".format(percentage)
|
||||||
|
solution = f"Required percentage = {formatted_float}%"
|
||||||
|
return problem, solution
|
||||||
Reference in New Issue
Block a user