mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
new 1s binary complement generated added .
new 1s binary complement problem generator added .
This commit is contained in:
@@ -50,6 +50,19 @@ def divisionFunc(maxRes = 99, maxDivid = 99):
|
||||
problem = str(a) + "/" + str(b) + "="
|
||||
solution = str(c)
|
||||
return problem, solution
|
||||
|
||||
def binary_1s_Complement(maxDigits = 10):
|
||||
question = ''
|
||||
answer = ''
|
||||
for i in range(random.randint(1,maxDigits)):
|
||||
temp = str(random.randint(0, 1))
|
||||
question += temp
|
||||
answer += "0" if temp == "1" else "1"
|
||||
|
||||
problem = question
|
||||
solution = answer
|
||||
return problem, solution
|
||||
|
||||
# || Class Instances
|
||||
|
||||
#Format is:
|
||||
@@ -58,4 +71,5 @@ addition = Generator("Addition", 2, "a+b=", "c", additionFunc)
|
||||
subtraction = Generator("Subtraction", 3, "a-b=", "c", subtractionFunc)
|
||||
multiplication = Generator("Multiplication", 4, "a*b=", "c", multiplicationFunc)
|
||||
division = Generator("Division", 5, "a/b=", "c", divisionFunc)
|
||||
binary_complement_1s = Generator("binary_complement_1s", 6, "(1010)=", "0101", binary_1s_Complement)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user