Files
mathgenerator/mathgenerator/funcs/computer_science/binary_to_decimal.py
Luke Weiler f2efb3751d import with name not asterisk
* import with name not *, remove top level imports

* Fix linter, remove numpy

* Lint fixes

* Comment worksheet generator temporarily
2022-12-19 01:31:08 -05:00

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