Update percentage_error.py

This commit is contained in:
Sankari Karthik
2021-10-09 15:55:13 +05:30
committed by GitHub
parent 29190bfadb
commit 82015bf4d5

View File

@@ -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"])