mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
* import with name not *, remove top level imports * Fix linter, remove numpy * Lint fixes * Comment worksheet generator temporarily
23 lines
538 B
Python
23 lines
538 B
Python
from ..__init__ import Generator
|
|
import random
|
|
|
|
|
|
def gen_func(max_dig=10, format='string'):
|
|
problem = ''
|
|
|
|
for i in range(random.randint(1, max_dig)):
|
|
temp = str(random.randint(0, 1))
|
|
problem += temp
|
|
|
|
if format == 'string':
|
|
solution = int(problem, 2)
|
|
return problem, solution
|
|
elif format == 'latex':
|
|
return "Latex unavailable"
|
|
else:
|
|
return problem, solution
|
|
|
|
|
|
binary_to_decimal = Generator("Binary to Decimal", 15, gen_func,
|
|
["max_dig=10"])
|