Merge pull request #216 from wjwelchusa/master

Added function binarytoHex()
This commit is contained in:
Luke Weiler
2020-10-18 22:53:11 -04:00
committed by GitHub

View File

@@ -984,6 +984,15 @@ def profitLossPercentFunc(maxCP = 1000, maxSP = 1000):
problem = f"{profitOrLoss} percent when CP = {cP} and SP = {sP} is: " problem = f"{profitOrLoss} percent when CP = {cP} and SP = {sP} is: "
solution = percent solution = percent
def BinaryToHexFunc(max_dig=10):
problem = ''
for i in range(random.randint(1, max_dig)):
temp = str(random.randint(0, 1))
problem += temp
solution = hex(int(problem, 2))
return problem, solution
# || Class Instances # || Class Instances
@@ -1107,4 +1116,5 @@ volumeSphere = Generator("Volume of Sphere", 60,
"Volume of sphere with radius r m = ", "(4*pi/3)*r*r*r", volumeSphereFunc) "Volume of sphere with radius r m = ", "(4*pi/3)*r*r*r", volumeSphereFunc)
nthFibonacciNumberGen = Generator("nth Fibonacci number", 61, "What is the nth Fibonacci number", "Fn", nthFibonacciNumber) nthFibonacciNumberGen = Generator("nth Fibonacci number", 61, "What is the nth Fibonacci number", "Fn", nthFibonacciNumber)
profitLossPercent = Generator("Profit or Loss Percent", 61, "Profit/ Loss percent when CP = cp and SP = sp is: ", "percent", profitLossPercentFunc) profitLossPercent = Generator("Profit or Loss Percent", 62, "Profit/ Loss percent when CP = cp and SP = sp is: ", "percent", profitLossPercentFunc)
binaryToHex = Generator("Binary to Hexidecimal", 63, "Hexidecimal of a=", "b", BinaryToHexFunc)