added latex unavailable message and scripts folder

This commit is contained in:
lukew3
2021-10-06 12:30:15 -04:00
parent b66a5bdec7
commit 7e7463e6a6
100 changed files with 384 additions and 21 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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,

View File

@@ -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"])

View File

@@ -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,

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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