mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
added latex unavailable message and scripts folder
This commit is contained in:
@@ -19,6 +19,8 @@ def BCDtoDecimalFunc(maxNumber=10000, format='string'):
|
||||
problem = "Integer of Binary Coded Decimal " + str(n) + " is = "
|
||||
solution = int(binstring, 2)
|
||||
return problem, solution
|
||||
elif format == 'latex':
|
||||
return "Latex unavailable"
|
||||
else:
|
||||
return n, int(binstring, 2)
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ def binary2sComplementFunc(maxDigits=10, format='string'):
|
||||
problem = "2's complement of " + question + " ="
|
||||
solution = ''.join(answer).lstrip('0')
|
||||
return problem, solution
|
||||
elif format == 'latex':
|
||||
return "Latex unavailable"
|
||||
else:
|
||||
return question, answer
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ def binaryComplement1sFunc(maxDigits=10, format='string'):
|
||||
if format == 'string':
|
||||
problem = question + "="
|
||||
return problem, answer
|
||||
elif format == 'latex':
|
||||
return "Latex unavailable"
|
||||
else:
|
||||
return problem, answer
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ def binaryToDecimalFunc(max_dig=10, format='string'):
|
||||
if format == 'string':
|
||||
solution = int(problem, 2)
|
||||
return problem, solution
|
||||
elif format == 'latex':
|
||||
return "Latex unavailable"
|
||||
else:
|
||||
return problem, solution
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ def binaryToHexFunc(max_dig=10, format='string'):
|
||||
if format == 'string':
|
||||
solution = hex(int(problem, 2))
|
||||
return problem, solution
|
||||
elif format == 'latex':
|
||||
return "Latex unavailable"
|
||||
else:
|
||||
return problem, solution
|
||||
|
||||
|
||||
@@ -11,9 +11,14 @@ def DecimalToBCDFunc(maxNumber=10000, format='string'):
|
||||
bcdstring = str(nibble) + bcdstring
|
||||
x >>= 4
|
||||
|
||||
problem = "BCD of Decimal Number " + str(n) + " is = "
|
||||
solution = int(bcdstring)
|
||||
return problem, solution
|
||||
if format == 'string':
|
||||
problem = "BCD of Decimal Number " + str(n) + " is = "
|
||||
solution = bcdstring
|
||||
return problem, solution
|
||||
elif format == 'latex':
|
||||
return "Latex unavailable"
|
||||
else:
|
||||
return n, int(bcdstring)
|
||||
|
||||
|
||||
decimal_to_bcd = Generator("Decimal to Binary Coded Decimal", 103,
|
||||
|
||||
@@ -5,11 +5,14 @@ def DecimalToBinaryFunc(max_dec=99, format='string'):
|
||||
a = random.randint(1, max_dec)
|
||||
b = bin(a).replace("0b", "")
|
||||
|
||||
problem = "Binary of " + str(a) + "="
|
||||
solution = str(b)
|
||||
|
||||
return problem, solution
|
||||
|
||||
if format == 'string':
|
||||
problem = "Binary of " + str(a) + "="
|
||||
solution = str(b)
|
||||
return problem, solution
|
||||
elif format == 'latex':
|
||||
return "Latex unavailable"
|
||||
else:
|
||||
return a, str(b)
|
||||
|
||||
decimal_to_binary = Generator("Decimal to Binary", 14, DecimalToBinaryFunc,
|
||||
["max_dec=99"])
|
||||
|
||||
@@ -4,10 +4,15 @@ from .__init__ import *
|
||||
def deciToHexaFunc(max_dec=1000, format='string'):
|
||||
a = random.randint(0, max_dec)
|
||||
b = hex(a)
|
||||
problem = "Binary of " + str(a) + "="
|
||||
solution = str(b)
|
||||
|
||||
return problem, solution
|
||||
if format == 'string':
|
||||
problem = "Binary of " + str(a) + "="
|
||||
solution = str(b)
|
||||
return problem, solution
|
||||
elif format == 'latex':
|
||||
return "Latex unavailable"
|
||||
else:
|
||||
return a, str(b)
|
||||
|
||||
|
||||
decimal_to_hexadeci = Generator("Decimal to Hexadecimal", 79, deciToHexaFunc,
|
||||
|
||||
@@ -8,6 +8,8 @@ def decimalToOctalFunc(maxDecimal=4096, format='string'):
|
||||
|
||||
if format == 'string':
|
||||
return problem, solution
|
||||
elif format == 'latex':
|
||||
return "Latex unavailable"
|
||||
else:
|
||||
return x, oct(x)
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ def fibonacciSeriesFunc(minNo=1, format='string'):
|
||||
problem = "The Fibonacci Series of the first " + str(
|
||||
n) + " numbers is ?"
|
||||
return problem, fibList
|
||||
elif format == 'latex':
|
||||
return "Latex unavailable"
|
||||
else:
|
||||
return n, fibList
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ def moduloFunc(maxRes=99, maxModulo=99, format='string'):
|
||||
problem = str(a) + "%" + str(b) + "="
|
||||
solution = str(c)
|
||||
return problem, solution
|
||||
elif format == 'latex':
|
||||
return "Latex unavailable"
|
||||
else:
|
||||
return a, b, c
|
||||
|
||||
|
||||
@@ -10,8 +10,9 @@ def nthFibonacciNumberFunc(maxN=100, format='string'):
|
||||
ans = int((math.pow(golden_ratio, n) - math.pow(-golden_ratio, -n)) / (math.sqrt(5)))
|
||||
|
||||
if format == 'string':
|
||||
solution = f"{ans}"
|
||||
return problem, solution
|
||||
return problem, str(ans)
|
||||
elif format == 'latex':
|
||||
return "Latex unavailable"
|
||||
else:
|
||||
return n, ans
|
||||
|
||||
|
||||
Reference in New Issue
Block a user