From f820ea9435b5de5a8ad30c1e4ecb884d90e35616 Mon Sep 17 00:00:00 2001 From: jsun1590 Date: Sun, 10 Oct 2021 16:38:34 +0800 Subject: [PATCH 1/6] Added product of scientific notations function --- README.md | 1 + mathgenerator/funcs/misc/__init__.py | 1 + .../misc/product_of_scientific_notations | 25 +++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 mathgenerator/funcs/misc/product_of_scientific_notations diff --git a/README.md b/README.md index 72380d0..5dfc913 100644 --- a/README.md +++ b/README.md @@ -191,6 +191,7 @@ This creates the pdf `ws.pdf` in your current directory | 102 | [Minute to Hour conversion](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/minutes_to_hours.py) | Convert 233 minutes to Hours & Minutes | 3 hours and 53 minutes | minutes_to_hours | `maxMinutes=999` | | 106 | [signum function](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/signum_function.py) | signum of -103 is = | -1 | signum_function | `min=-999` `max=999` | | 109 | [Binomial distribution](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/binomial_distribution.py) | A manufacturer of metal pistons finds that, on average, 31.73% of the pistons they manufacture are rejected because they are incorrectly sized. What is the probability that a batch of 11 pistons will contain no more than 5 rejected pistons? | 90.06 | binomial_distribution | `` | +| 115 | [Product of scientific notations](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/product_of_scientific_notations.py) | Product of scientific notations: 5.12x10^93 6.28x10^73 = | 3.22x10^167 | product_of_scientific_notations | `minExpVal=-100` `maxExpVal=100` | ## statistics | Id | Skill | Example problem | Example Solution | Function Name | Kwargs | |------|-------|-----------------|------------------|---------------|--------| diff --git a/mathgenerator/funcs/misc/__init__.py b/mathgenerator/funcs/misc/__init__.py index 41f52e3..8aa17b6 100644 --- a/mathgenerator/funcs/misc/__init__.py +++ b/mathgenerator/funcs/misc/__init__.py @@ -25,3 +25,4 @@ from .quotient_of_power_same_power import * from .set_operation import * from .signum_function import * from .surds_comparison import * +from .scientific_notation_multiplication import * \ No newline at end of file diff --git a/mathgenerator/funcs/misc/product_of_scientific_notations b/mathgenerator/funcs/misc/product_of_scientific_notations new file mode 100644 index 0000000..0c1ecd4 --- /dev/null +++ b/mathgenerator/funcs/misc/product_of_scientific_notations @@ -0,0 +1,25 @@ +from .__init__ import * + + +def gen_func(minExpVal=-100, maxExpVal=100, format='string'): + a = [round(random.uniform(1,10), 2), random.randint(minExpVal, maxExpVal)] + b = [round(random.uniform(1,10), 2), random.randint(minExpVal, maxExpVal)] + c = [a[0]*b[0], a[1]+b[1]] + + if c[0] >= 10: + c[0] /= 10 + c[1] += 1 + + if format == 'string': + problem = "Product of scientific notations: " + \ + str(a[0])+"x10^"+str(a[1]) + " " + str(b[0])+"x10^"+str(b[1]) + " = " + solution = str(round(c[0], 2))+"x10^"+str(c[1]) + return problem, solution + elif format == 'latex': + return "Latex unavailable" + else: + return a, b, c + + +product_of_scientific_notations = Generator("Product of scientific notaions", 115, gen_func, + ["minExpVal=-100", "maxExpVal=100"]) From 11c3215a3de61e277a9901a254fb6f2b7bb0d0ff Mon Sep 17 00:00:00 2001 From: jsun1590 Date: Sun, 10 Oct 2021 16:40:57 +0800 Subject: [PATCH 2/6] fixed problem sentence structure --- mathgenerator/funcs/misc/product_of_scientific_notations | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mathgenerator/funcs/misc/product_of_scientific_notations b/mathgenerator/funcs/misc/product_of_scientific_notations index 0c1ecd4..1d537b4 100644 --- a/mathgenerator/funcs/misc/product_of_scientific_notations +++ b/mathgenerator/funcs/misc/product_of_scientific_notations @@ -12,7 +12,7 @@ def gen_func(minExpVal=-100, maxExpVal=100, format='string'): if format == 'string': problem = "Product of scientific notations: " + \ - str(a[0])+"x10^"+str(a[1]) + " " + str(b[0])+"x10^"+str(b[1]) + " = " + str(a[0])+"x10^"+str(a[1]) + " and " + str(b[0])+"x10^"+str(b[1]) + " = " solution = str(round(c[0], 2))+"x10^"+str(c[1]) return problem, solution elif format == 'latex': From 1787f6ecb1db6f5723b200aadb8a7234e1893ac6 Mon Sep 17 00:00:00 2001 From: jsun1590 Date: Sun, 10 Oct 2021 16:41:56 +0800 Subject: [PATCH 3/6] revised readme --- README.md | 2 +- mathgenerator/funcs/misc/product_of_scientific_notations | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5dfc913..b5c4249 100644 --- a/README.md +++ b/README.md @@ -191,7 +191,7 @@ This creates the pdf `ws.pdf` in your current directory | 102 | [Minute to Hour conversion](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/minutes_to_hours.py) | Convert 233 minutes to Hours & Minutes | 3 hours and 53 minutes | minutes_to_hours | `maxMinutes=999` | | 106 | [signum function](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/signum_function.py) | signum of -103 is = | -1 | signum_function | `min=-999` `max=999` | | 109 | [Binomial distribution](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/binomial_distribution.py) | A manufacturer of metal pistons finds that, on average, 31.73% of the pistons they manufacture are rejected because they are incorrectly sized. What is the probability that a batch of 11 pistons will contain no more than 5 rejected pistons? | 90.06 | binomial_distribution | `` | -| 115 | [Product of scientific notations](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/product_of_scientific_notations.py) | Product of scientific notations: 5.12x10^93 6.28x10^73 = | 3.22x10^167 | product_of_scientific_notations | `minExpVal=-100` `maxExpVal=100` | +| 115 | [Product of scientific notations](https://github.com/lukew3/mathgenerator/blob/main/mathgenerator/funcs/misc/product_of_scientific_notations.py) | Product of scientific notations 5.12x10^93 and 6.28x10^73 = | 3.22x10^167 | product_of_scientific_notations | `minExpVal=-100` `maxExpVal=100` | ## statistics | Id | Skill | Example problem | Example Solution | Function Name | Kwargs | |------|-------|-----------------|------------------|---------------|--------| diff --git a/mathgenerator/funcs/misc/product_of_scientific_notations b/mathgenerator/funcs/misc/product_of_scientific_notations index 1d537b4..87b7f90 100644 --- a/mathgenerator/funcs/misc/product_of_scientific_notations +++ b/mathgenerator/funcs/misc/product_of_scientific_notations @@ -11,7 +11,7 @@ def gen_func(minExpVal=-100, maxExpVal=100, format='string'): c[1] += 1 if format == 'string': - problem = "Product of scientific notations: " + \ + problem = "Product of scientific notations " + \ str(a[0])+"x10^"+str(a[1]) + " and " + str(b[0])+"x10^"+str(b[1]) + " = " solution = str(round(c[0], 2))+"x10^"+str(c[1]) return problem, solution From 3f155ecce4f7cae4d8d66dead6ab3b36b7428afc Mon Sep 17 00:00:00 2001 From: jsun1590 <40915904+jsun1590@users.noreply.github.com> Date: Sun, 10 Oct 2021 16:49:50 +0800 Subject: [PATCH 4/6] added newline at end of __init__.py --- mathgenerator/funcs/misc/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mathgenerator/funcs/misc/__init__.py b/mathgenerator/funcs/misc/__init__.py index 8aa17b6..179897b 100644 --- a/mathgenerator/funcs/misc/__init__.py +++ b/mathgenerator/funcs/misc/__init__.py @@ -25,4 +25,4 @@ from .quotient_of_power_same_power import * from .set_operation import * from .signum_function import * from .surds_comparison import * -from .scientific_notation_multiplication import * \ No newline at end of file +from .scientific_notation_multiplication import * From 4490b24c4c5d0026d306843798bd8663a5c5c64b Mon Sep 17 00:00:00 2001 From: jsun1590 <40915904+jsun1590@users.noreply.github.com> Date: Sun, 10 Oct 2021 16:52:24 +0800 Subject: [PATCH 5/6] updated generator name --- mathgenerator/funcs/misc/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mathgenerator/funcs/misc/__init__.py b/mathgenerator/funcs/misc/__init__.py index 179897b..5ea41d1 100644 --- a/mathgenerator/funcs/misc/__init__.py +++ b/mathgenerator/funcs/misc/__init__.py @@ -25,4 +25,4 @@ from .quotient_of_power_same_power import * from .set_operation import * from .signum_function import * from .surds_comparison import * -from .scientific_notation_multiplication import * +from .product_of_scientific_notations import * From a1da1357c4116f45e66de5f9a570ae2939dbbf3f Mon Sep 17 00:00:00 2001 From: jsun1590 <40915904+jsun1590@users.noreply.github.com> Date: Sun, 10 Oct 2021 16:54:09 +0800 Subject: [PATCH 6/6] Rename product_of_scientific_notations to product_of_scientific_notations.py --- ...of_scientific_notations => product_of_scientific_notations.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename mathgenerator/funcs/misc/{product_of_scientific_notations => product_of_scientific_notations.py} (100%) diff --git a/mathgenerator/funcs/misc/product_of_scientific_notations b/mathgenerator/funcs/misc/product_of_scientific_notations.py similarity index 100% rename from mathgenerator/funcs/misc/product_of_scientific_notations rename to mathgenerator/funcs/misc/product_of_scientific_notations.py