mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
Merge pull request #255 from Souvikdeb2612/master
Added percentage function
This commit is contained in:
@@ -82,3 +82,4 @@ from .meanMedianFunc import*
|
|||||||
from .determinantToMatrix22 import *
|
from .determinantToMatrix22 import *
|
||||||
from .compoundInterestFunc import *
|
from .compoundInterestFunc import *
|
||||||
from .deciToHexaFunc import *
|
from .deciToHexaFunc import *
|
||||||
|
from .percentageFunc import *
|
||||||
|
|||||||
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
|
||||||
@@ -115,3 +115,4 @@ meanMedian=Generator("Mean and Median", 76,"Mean and median of given set of numb
|
|||||||
intMatrix22determinant = Generator("Determinant to 2x2 Matrix", 77, "Det([[a,b],[c,d]]) =", " a * d - b * c", determinantToMatrix22)
|
intMatrix22determinant = Generator("Determinant to 2x2 Matrix", 77, "Det([[a,b],[c,d]]) =", " a * d - b * c", determinantToMatrix22)
|
||||||
compoundInterest = Generator("Compound Interest", 78, "Compound interest for a principle amount of p dollars, r% rate of interest and for a time period of t years with n times compounded annually is = ", "A dollars", compoundInterestFunc)
|
compoundInterest = Generator("Compound Interest", 78, "Compound interest for a principle amount of p dollars, r% rate of interest and for a time period of t years with n times compounded annually is = ", "A dollars", compoundInterestFunc)
|
||||||
decimalToHexadeci = Generator("Decimal to Hexadecimal", 79,"Binary of a=", "b", deciToHexaFunc)
|
decimalToHexadeci = Generator("Decimal to Hexadecimal", 79,"Binary of a=", "b", deciToHexaFunc)
|
||||||
|
percentage = Generator("Percentage of a number",80,"What is a% of b?","percentage",percentageFunc)
|
||||||
|
|||||||
Reference in New Issue
Block a user