Merge pull request #367 from Sankari-K/main

Added generator for percent difference
This commit is contained in:
Luke Weiler
2021-10-12 15:46:59 -04:00
committed by GitHub
3 changed files with 26 additions and 1 deletions

View File

@@ -14,6 +14,7 @@ from .greatest_common_divisor import *
from .is_prime import *
from .multiplication import *
from .percentage import *
from .percentage_difference import *
from .percentage_error import *
from .power_of_powers import *
from .square import *

View File

@@ -0,0 +1,24 @@
from .__init__ import *
def gen_func(maxValue=200, minValue=0, format='string'):
value_a = random.randint(minValue, maxValue)
value_b = random.randint(minValue, maxValue)
diff = 2 * (abs(value_a - value_b) / abs(value_a + value_b)) * 100
diff = round(diff, 2)
if format == 'string':
problem = f"What is the percentage difference between {value_a} and {value_b}?"
solution = str(diff) + "%"
return problem, solution
elif format == 'latex':
return 'Latex unavailable'
else:
return value_a, value_b, diff
percentage_difference = Generator("Percentage difference", <id>, gen_func,
["maxValue=200", "minValue=0"])

View File

@@ -19,10 +19,10 @@ from .is_leap_year import *
from .lcm import *
from .minutes_to_hours import *
from .prime_factors import *
from .product_of_scientific_notations import *
from .profit_loss_percent import *
from .quotient_of_power_same_base import *
from .quotient_of_power_same_power import *
from .set_operation import *
from .signum_function import *
from .surds_comparison import *
from .product_of_scientific_notations import *