mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
Update percentage_error.py
This commit is contained in:
@@ -4,9 +4,12 @@ from .__init__ import *
|
||||
def gen_func(maxValue=100, minValue=-100, format='string'):
|
||||
observed_value = random.randint(minValue, maxValue)
|
||||
exact_value = random.randint(minValue, maxValue)
|
||||
|
||||
error = (abs(observed_value - exact_value)/abs(exact_value))*100
|
||||
error = round(error,2)
|
||||
|
||||
if observed_value * exact_value < 0:
|
||||
observed_value *= -1
|
||||
|
||||
error = (abs(observed_value - exact_value) / abs(exact_value)) * 100
|
||||
error = round(error, 2)
|
||||
|
||||
if format == 'string':
|
||||
problem = f"Find the percentage error when observed value equals {observed_value} and exact value equals {exact_value}."
|
||||
@@ -20,5 +23,6 @@ def gen_func(maxValue=100, minValue=-100, format='string'):
|
||||
return observed_value, exact_value, error
|
||||
|
||||
|
||||
percentage_error = Generator("Percentage error", <id>, gen_func,
|
||||
["maxValue=100", "minValue=-100"])
|
||||
percentage_error = Generator(
|
||||
"Percentage error", <id>, gen_func,
|
||||
["maxValue=100", "minValue=-100"])
|
||||
|
||||
Reference in New Issue
Block a user