mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
24 lines
617 B
Python
24 lines
617 B
Python
from .__init__ import *
|
|
from ..__init__ import Generator
|
|
|
|
|
|
def profitLossPercentFunc(maxCP=1000, maxSP=1000):
|
|
cP = random.randint(1, maxCP)
|
|
sP = random.randint(1, maxSP)
|
|
diff = abs(sP - cP)
|
|
if (sP - cP >= 0):
|
|
profitOrLoss = "Profit"
|
|
else:
|
|
profitOrLoss = "Loss"
|
|
percent = diff / cP * 100
|
|
problem = f"{profitOrLoss} percent when CP = {cP} and SP = {sP} is: "
|
|
solution = percent
|
|
|
|
return problem, solution
|
|
|
|
|
|
profitLossPercent = Generator(
|
|
"Profit or Loss Percent", 63,
|
|
"Profit/ Loss percent when CP = cp and SP = sp is: ", "percent",
|
|
profitLossPercentFunc)
|