mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
Added function binarytoHex()
This commit is contained in:
12
driver.py
Normal file
12
driver.py
Normal file
@@ -0,0 +1,12 @@
|
||||
# First test to run mathgenerator
|
||||
# 19 Oct 2020
|
||||
|
||||
from mathgenerator import mathgen
|
||||
|
||||
problem, solution = mathgen.addition()
|
||||
print(problem)
|
||||
print(solution)
|
||||
|
||||
problem, solution = mathgen.binarytohex()
|
||||
print(problem)
|
||||
print(solution)
|
||||
@@ -920,6 +920,16 @@ def volumeSphereFunc(maxRadius = 100):
|
||||
ans=(4*math.pi/3)*r*r*r
|
||||
solution = f"{ans} m^3"
|
||||
return problem,solution
|
||||
|
||||
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
|
||||
|
||||
# Format is:
|
||||
@@ -986,3 +996,4 @@ sumOfAnglesOfPolygon = Generator("Sum of Angles of Polygon", 58, "Sum of angles
|
||||
dataSummary = Generator("Mean,Standard Deviation,Variance", 59, "a,b,c", "Mean:a+b+c/3,Std,Var", dataSummaryFunc)
|
||||
surfaceAreaSphereGen = Generator("Surface Area of Sphere", 59, "Surface area of sphere with radius = a units is","d units^2", surfaceAreaSphere)
|
||||
volumeSphere=Generator("Volume of Sphere",60,"Volume of sphere with radius r m = ","(4*pi/3)*r*r*r",volumeSphereFunc)
|
||||
binaryToHex = Generator("Binary to Hexidecimal", 61, "Hexidecimal of a=", "b", BinaryToHexFunc)
|
||||
|
||||
Reference in New Issue
Block a user