Merge pull request #255 from Souvikdeb2612/master

Added percentage function
This commit is contained in:
Luke Weiler
2020-10-19 13:40:05 -04:00
committed by GitHub
3 changed files with 12 additions and 0 deletions

View File

@@ -82,3 +82,4 @@ from .meanMedianFunc import*
from .determinantToMatrix22 import *
from .compoundInterestFunc import *
from .deciToHexaFunc import *
from .percentageFunc import *

View 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

View File

@@ -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)
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)
percentage = Generator("Percentage of a number",80,"What is a% of b?","percentage",percentageFunc)