From 88bf96f4e6e26c8bed5549121da333aa035b89c3 Mon Sep 17 00:00:00 2001 From: Satyam Koshta <58166232+satyamkoshta340@users.noreply.github.com> Date: Mon, 19 Oct 2020 10:51:33 +0530 Subject: [PATCH 01/18] Add files via upload adding solution for isprime number --- mathgen.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 mathgen.py diff --git a/mathgen.py b/mathgen.py new file mode 100644 index 0000000..60e5981 --- /dev/null +++ b/mathgen.py @@ -0,0 +1,32 @@ +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): + a =random.randint(2,max_a) + problem =a + if a == 2: + solution = True + return problem,solution + if a % 2 == 0: + solution = False + return problem,solution + for i in range(3, a // 2 + 1, 2): + if a % i == 0: + solution = False + return problem, solution + solution = True + return problem, solution + +is_prime = Generator("isprime", 61, "a any positive integer", "True/False", isprime) From a0fe001e60077779824b0ad25fc36a33c28d8f91 Mon Sep 17 00:00:00 2001 From: Satyam Koshta <58166232+satyamkoshta340@users.noreply.github.com> Date: Mon, 19 Oct 2020 11:11:26 +0530 Subject: [PATCH 02/18] Update mathgen.py --- mathgen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mathgen.py b/mathgen.py index 60e5981..6ee4b89 100644 --- a/mathgen.py +++ b/mathgen.py @@ -29,4 +29,4 @@ def isprime(max_a =100): solution = True return problem, solution -is_prime = Generator("isprime", 61, "a any positive integer", "True/False", isprime) +is_prime = Generator("isprime", 61, "a any positive integer", "True/False", isprime()) From d2d224425a3317588a93efea32eee63922277fd5 Mon Sep 17 00:00:00 2001 From: Satyam Koshta <58166232+satyamkoshta340@users.noreply.github.com> Date: Mon, 19 Oct 2020 11:23:14 +0530 Subject: [PATCH 03/18] Create isprime.py Added solution for isprime --- mathgenerator/funcs/isprime.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 mathgenerator/funcs/isprime.py diff --git a/mathgenerator/funcs/isprime.py b/mathgenerator/funcs/isprime.py new file mode 100644 index 0000000..c45138c --- /dev/null +++ b/mathgenerator/funcs/isprime.py @@ -0,0 +1,18 @@ +__init__ import * +def isprime(max_a =100): + a =random.randint(2,max_a) + problem =a + if a == 2: + solution = True + return problem,solution + if a % 2 == 0: + solution = False + return problem,solution + for i in range(3, a // 2 + 1, 2): + if a % i == 0: + solution = False + return problem, solution + solution = True + return problem, solution + +is_prime = Generator("isprime", 61, "a any positive integer", "True/False", isprime()) From da33be5469d9104dc6e4e9abaa08cc802731cfc3 Mon Sep 17 00:00:00 2001 From: Satyam Koshta <58166232+satyamkoshta340@users.noreply.github.com> Date: Mon, 19 Oct 2020 11:24:33 +0530 Subject: [PATCH 04/18] Update __init__.py --- mathgenerator/funcs/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mathgenerator/funcs/__init__.py b/mathgenerator/funcs/__init__.py index efb1ce7..457a4ae 100644 --- a/mathgenerator/funcs/__init__.py +++ b/mathgenerator/funcs/__init__.py @@ -71,3 +71,4 @@ from .multiplyComplexNumbersFunc import * from .geomProgrFunc import * from .geometricMeanFunc import * from .harmonicMeanFunc import * +from .isprime import * From dbccb4d38a470859ad23f302f2b41b679727666d Mon Sep 17 00:00:00 2001 From: Satyam Koshta <58166232+satyamkoshta340@users.noreply.github.com> Date: Mon, 19 Oct 2020 11:25:35 +0530 Subject: [PATCH 05/18] Update isprime.py --- mathgenerator/funcs/isprime.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mathgenerator/funcs/isprime.py b/mathgenerator/funcs/isprime.py index c45138c..fee046e 100644 --- a/mathgenerator/funcs/isprime.py +++ b/mathgenerator/funcs/isprime.py @@ -1,4 +1,4 @@ -__init__ import * +.__init__ import * def isprime(max_a =100): a =random.randint(2,max_a) problem =a @@ -15,4 +15,4 @@ def isprime(max_a =100): solution = True return problem, solution -is_prime = Generator("isprime", 61, "a any positive integer", "True/False", isprime()) +is_prime = Generator("isprime", 74, "a any positive integer", "True/False", isprime()) From 9805f810910f4019f57b3c99d925641d8d386218 Mon Sep 17 00:00:00 2001 From: Satyam Koshta <58166232+satyamkoshta340@users.noreply.github.com> Date: Mon, 19 Oct 2020 11:32:01 +0530 Subject: [PATCH 06/18] Update mathgen.py --- mathgen.py | 58 +++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/mathgen.py b/mathgen.py index 6ee4b89..3eb6ea8 100644 --- a/mathgen.py +++ b/mathgen.py @@ -1,32 +1,32 @@ -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) +# 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): - a =random.randint(2,max_a) - problem =a - if a == 2: - solution = True - return problem,solution - if a % 2 == 0: - solution = False - return problem,solution - for i in range(3, a // 2 + 1, 2): - if a % i == 0: - solution = False - return problem, solution - solution = True - return problem, solution +# def isprime(max_a =100): +# a =random.randint(2,max_a) +# problem =a +# if a == 2: +# solution = True +# return problem,solution +# if a % 2 == 0: +# solution = False +# return problem,solution +# for i in range(3, a // 2 + 1, 2): +# if a % i == 0: +# solution = False +# return problem, solution +# solution = True +# return problem, solution is_prime = Generator("isprime", 61, "a any positive integer", "True/False", isprime()) From 1023beeb9badece0869b3f3c3e94b46a97c939ed Mon Sep 17 00:00:00 2001 From: Satyam Koshta <58166232+satyamkoshta340@users.noreply.github.com> Date: Mon, 19 Oct 2020 11:33:25 +0530 Subject: [PATCH 07/18] Update isprime.py --- mathgenerator/funcs/isprime.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mathgenerator/funcs/isprime.py b/mathgenerator/funcs/isprime.py index fee046e..7851f9a 100644 --- a/mathgenerator/funcs/isprime.py +++ b/mathgenerator/funcs/isprime.py @@ -15,4 +15,4 @@ def isprime(max_a =100): solution = True 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()) From 8e6388d661590880e1ccd00bbb9ec4b7855cc7a6 Mon Sep 17 00:00:00 2001 From: Satyam Koshta <58166232+satyamkoshta340@users.noreply.github.com> Date: Mon, 19 Oct 2020 11:41:18 +0530 Subject: [PATCH 08/18] Update mathgen.py --- mathgen.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/mathgen.py b/mathgen.py index 3eb6ea8..71c2c7a 100644 --- a/mathgen.py +++ b/mathgen.py @@ -13,20 +13,20 @@ # def __call__(self, **kwargs): # return self.func(**kwargs) -# def isprime(max_a =100): -# a =random.randint(2,max_a) -# problem =a -# if a == 2: -# solution = True -# return problem,solution -# if a % 2 == 0: -# solution = False -# return problem,solution -# for i in range(3, a // 2 + 1, 2): -# if a % i == 0: -# solution = False -# return problem, solution -# solution = True -# return problem, solution +def isprime(max_a =100): + a =random.randint(2,max_a) + problem =a + if a == 2: + solution = True + return problem,solution + if a % 2 == 0: + solution = False + return problem,solution + for i in range(3, a // 2 + 1, 2): + if a % i == 0: + solution = False + return problem, solution + solution = True + return problem, solution -is_prime = Generator("isprime", 61, "a any positive integer", "True/False", isprime()) +is_prime = Generator("isprime", 74, "a any positive integer", "True/False", isprime()) From 81cbc2123828c2cd358632bb7582a2df31227457 Mon Sep 17 00:00:00 2001 From: Satyam Koshta <58166232+satyamkoshta340@users.noreply.github.com> Date: Mon, 19 Oct 2020 13:34:31 +0530 Subject: [PATCH 09/18] Update mathgen.py --- mathgen.py | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/mathgen.py b/mathgen.py index 71c2c7a..0496c70 100644 --- a/mathgen.py +++ b/mathgen.py @@ -1,32 +1,16 @@ -# 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): - a =random.randint(2,max_a) - problem =a +def isprime(max_a = 100): + a = random.randint(2, max_a) + problem = a if a == 2: solution = True - return problem,solution - if a % 2 == 0: + return problem, solution + if a%2 == 0: solution = False return problem,solution - for i in range(3, a // 2 + 1, 2): - if a % i == 0: + for i in range(3, (a//2)+1, 2): + if a%i == 0: solution = False return problem, solution solution = True 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) From 900da1cb36707ad72dd0c56b2b70c71e7cea8e62 Mon Sep 17 00:00:00 2001 From: Satyam Koshta <58166232+satyamkoshta340@users.noreply.github.com> Date: Mon, 19 Oct 2020 13:38:37 +0530 Subject: [PATCH 10/18] Update mathgen.py --- mathgen.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/mathgen.py b/mathgen.py index 0496c70..b0a426a 100644 --- a/mathgen.py +++ b/mathgen.py @@ -1,16 +1,23 @@ -def isprime(max_a = 100): +#!/usr/bin/python +# -*- coding: utf-8 -*- + + +def isprime(max_a=100): a = random.randint(2, max_a) problem = a if a == 2: solution = True - return problem, solution - if a%2 == 0: + return (problem, solution) + if a % 2 == 0: solution = False - return problem,solution - for i in range(3, (a//2)+1, 2): - if a%i == 0: + return (problem, solution) + for i in range(3, a // 2 + 1, 2): + if a % i == 0: solution = False - return problem, solution + return (problem, solution) solution = True - return problem, solution -is_prime = Generator("isprime", 74, "a any positive integer", "True/False", isprime) + return (problem, solution) + + +is_prime = Generator('isprime', 74, 'a any positive integer', + 'True/False', isprime) From 2e55c7798a06e7b70139dadc67e9adafdaac7a38 Mon Sep 17 00:00:00 2001 From: Satyam Koshta <58166232+satyamkoshta340@users.noreply.github.com> Date: Mon, 19 Oct 2020 14:19:54 +0530 Subject: [PATCH 11/18] Update isprime.py --- mathgenerator/funcs/isprime.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mathgenerator/funcs/isprime.py b/mathgenerator/funcs/isprime.py index 7851f9a..b24b2c1 100644 --- a/mathgenerator/funcs/isprime.py +++ b/mathgenerator/funcs/isprime.py @@ -1,18 +1,18 @@ .__init__ import * -def isprime(max_a =100): - a =random.randint(2,max_a) - problem =a + + +def isprime(max_a=100): + a = random.randint(2, max_a) + problem = a if a == 2: solution = True - return problem,solution + return (problem, solution) if a % 2 == 0: solution = False - return problem,solution + return (problem, solution) for i in range(3, a // 2 + 1, 2): if a % i == 0: solution = False - return problem, solution + return (problem, solution) solution = True - return problem, solution - -# is_prime = Generator("isprime", 74, "a any positive integer", "True/False", isprime()) + return (problem, solution) From eadc644e0da40a6975966794dd22f9b2b9b9425f Mon Sep 17 00:00:00 2001 From: Satyam Koshta <58166232+satyamkoshta340@users.noreply.github.com> Date: Mon, 19 Oct 2020 14:32:43 +0530 Subject: [PATCH 12/18] Update mathgen.py --- mathgen.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/mathgen.py b/mathgen.py index b0a426a..85a8f3d 100644 --- a/mathgen.py +++ b/mathgen.py @@ -1,5 +1,24 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- +import random + + +genList = [] + + +# || Generator class +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): From 653d043898992a69b2abf8ad97ddd2b9edf7eae4 Mon Sep 17 00:00:00 2001 From: Satyam Koshta <58166232+satyamkoshta340@users.noreply.github.com> Date: Mon, 19 Oct 2020 15:16:08 +0530 Subject: [PATCH 13/18] Update isprime.py --- mathgenerator/funcs/isprime.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mathgenerator/funcs/isprime.py b/mathgenerator/funcs/isprime.py index b24b2c1..9f79464 100644 --- a/mathgenerator/funcs/isprime.py +++ b/mathgenerator/funcs/isprime.py @@ -1,4 +1,4 @@ -.__init__ import * +__init__ import * def isprime(max_a=100): From e467f7ec7c641382fb0a7870fffa553a9da2f5a0 Mon Sep 17 00:00:00 2001 From: Satyam Koshta <58166232+satyamkoshta340@users.noreply.github.com> Date: Mon, 19 Oct 2020 15:35:25 +0530 Subject: [PATCH 14/18] Update isprime.py --- mathgenerator/funcs/isprime.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mathgenerator/funcs/isprime.py b/mathgenerator/funcs/isprime.py index 9f79464..ce5a58d 100644 --- a/mathgenerator/funcs/isprime.py +++ b/mathgenerator/funcs/isprime.py @@ -1,4 +1,4 @@ -__init__ import * +from __init__ import * def isprime(max_a=100): From 611469ec38de3521aca10b74cff87cdf63860008 Mon Sep 17 00:00:00 2001 From: Satyam Koshta <58166232+satyamkoshta340@users.noreply.github.com> Date: Tue, 20 Oct 2020 07:20:33 +0530 Subject: [PATCH 15/18] Update mathgen.py --- mathgen.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mathgen.py b/mathgen.py index 85a8f3d..ffb2ebe 100644 --- a/mathgen.py +++ b/mathgen.py @@ -40,3 +40,4 @@ def isprime(max_a=100): is_prime = Generator('isprime', 74, 'a any positive integer', 'True/False', isprime) +print(is_prime.func) From 979e9fa9f11fae428de6492b9d3a1d0df259d01d Mon Sep 17 00:00:00 2001 From: Satyam Koshta <58166232+satyamkoshta340@users.noreply.github.com> Date: Tue, 20 Oct 2020 07:26:44 +0530 Subject: [PATCH 16/18] Update isprime.py --- mathgenerator/funcs/isprime.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mathgenerator/funcs/isprime.py b/mathgenerator/funcs/isprime.py index ce5a58d..b24b2c1 100644 --- a/mathgenerator/funcs/isprime.py +++ b/mathgenerator/funcs/isprime.py @@ -1,4 +1,4 @@ -from __init__ import * +.__init__ import * def isprime(max_a=100): From 8bf56dc57d1654bdd73bf1991db7a3b54adfd6b6 Mon Sep 17 00:00:00 2001 From: Satyam Koshta <58166232+satyamkoshta340@users.noreply.github.com> Date: Tue, 20 Oct 2020 07:31:26 +0530 Subject: [PATCH 17/18] Update isprime.py --- mathgenerator/funcs/isprime.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mathgenerator/funcs/isprime.py b/mathgenerator/funcs/isprime.py index b24b2c1..ce5a58d 100644 --- a/mathgenerator/funcs/isprime.py +++ b/mathgenerator/funcs/isprime.py @@ -1,4 +1,4 @@ -.__init__ import * +from __init__ import * def isprime(max_a=100): From 047cd7289e76ebe508058118283f28bdca93b856 Mon Sep 17 00:00:00 2001 From: Satyam Koshta <58166232+satyamkoshta340@users.noreply.github.com> Date: Tue, 20 Oct 2020 07:38:20 +0530 Subject: [PATCH 18/18] Update isprime.py --- mathgenerator/funcs/isprime.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mathgenerator/funcs/isprime.py b/mathgenerator/funcs/isprime.py index ce5a58d..9da7bfb 100644 --- a/mathgenerator/funcs/isprime.py +++ b/mathgenerator/funcs/isprime.py @@ -1,4 +1,4 @@ -from __init__ import * +from .__init__ import * def isprime(max_a=100):