Files
mathgenerator/mathgenerator/funcs/profitLossPercentFunc.py
2020-10-19 17:43:04 +04:00

16 lines
423 B
Python

from .__init__ import *
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