Update mathgen.py

This commit is contained in:
Satyam Koshta
2020-10-19 13:34:31 +05:30
committed by GitHub
parent 8e6388d661
commit 81cbc21238

View File

@@ -1,18 +1,3 @@
# import random
# genList =[]
# class Generator:
# def __init__(self, title, id, generalProb, generalSol, func):
# self.title = title
# self.id = id
# self.generalProb = generalProb
# self.generalSol = generalSol
# self.func = func
# genList.append([id, title, self])
# def __str__(self):
# return str(self.id) + " " + self.title + " " + self.generalProb + " " + self.generalSol
# def __call__(self, **kwargs):
# return self.func(**kwargs)
def isprime(max_a = 100): def isprime(max_a = 100):
a = random.randint(2, max_a) a = random.randint(2, max_a)
problem = a problem = a
@@ -22,11 +7,10 @@ def isprime(max_a =100):
if a%2 == 0: if a%2 == 0:
solution = False solution = False
return problem,solution return problem,solution
for i in range(3, a // 2 + 1, 2): for i in range(3, (a//2)+1, 2):
if a%i == 0: if a%i == 0:
solution = False solution = False
return problem, solution return problem, solution
solution = True solution = True
return problem, solution return problem, solution
is_prime = Generator("isprime", 74, "a any positive integer", "True/False", isprime)
is_prime = Generator("isprime", 74, "a any positive integer", "True/False", isprime())