mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
* removed asterisk imports from subject inits * import Generator from the right init level
21 lines
505 B
Python
21 lines
505 B
Python
from ...__init__ import Generator
|
|
import random
|
|
|
|
|
|
def gen_func(max_dec=99, format='string'):
|
|
a = random.randint(1, max_dec)
|
|
b = bin(a).replace("0b", "")
|
|
|
|
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, gen_func,
|
|
["max_dec=99"])
|