def decimal_divide(): ans = gen_rand_decimal(3, 2) n1 = randint(2, 12) n2 = n1 * ans q = question(None, f'{n2} ÷ {n1} =', f'{ans}', 'decimal', level, 'Express your answer in Decimal') return q
def faction_add(): n1 = Fraction(randint(1, 9), randint(9, 15)) n2 = Fraction(randint(2, 9), randint(9, 16)) ans = n1 + n2 q = question(None, f'{n1} + {n2} =', f'{ans}', 'fraction', level, 'Express your answer in Simplified Fraction') return q
def integer_divide(): ans = gen_rand_int(randint(1, 3)) n1 = randint(2, 12) n2 = n1 * ans q = question(None, f'{n2} ÷ {n1} =', f'{ans}', 'int', level, 'Express your answer in number') return q
def decimal_multiply(): n1 = gen_rand_decimal(1, 2) n2 = gen_rand_decimal(1, 1) ans = n1 * n2 q = question(None, f'{n1} * {n2} =', f'{ans}', 'decimal', level, 'Express your answer in Decimal') return q
def decimal_add(): n1 = gen_rand_decimal(2, 2) n2 = gen_rand_decimal(3, 1) ans = n1 + n2 q = question(None, f'{n1} + {n2} =', f'{ans}', 'decimal', level, 'Express your answer in Decimal') return q
def integer_multiply(): n1 = gen_rand_int(randint(1, 3)) n2 = gen_rand_int(randint(1, 2)) ans = n1 * n2 q = question(None, f'{n1} * {n2} =', f'{ans}', 'int', level, 'Express your answer in number') return q
def integer_add(): n1 = gen_rand_int(randint(1, 5)) n2 = gen_rand_int(randint(1, 4)) ans = n1 + n2 q = question(None, f'{n1} + {n2} =', f'{ans}', 'int', level, 'Express your answer in number') return q
def faction_add_minus(): n1 = Fraction(randint(2, 6), randint(6, 12)) n2 = Fraction(randint(3, 9), randint(9, 15)) n3 = Fraction(randint(1, 4), randint(10, 15)) ans = n1 + n2 - n3 q = question(None, f'{n1} + {n2} - {n3} =', f'{ans}', 'fraction', level, 'Express your answer in Simplified Fraction') return q
def faction_minus(): n1 = Fraction(randint(1, 9), randint(9, 12)) n2 = Fraction(randint(2, 9), randint(9, 16)) if n1 < n2: tmp = n1 n1 = n2 n2 = tmp ans = n1 - n2 q = question(None, f'{n1} - {n2} =', f'{ans}', 'fraction', level, 'Express your answer in Simplified Fraction') return q
def decimal_minus(): n1 = gen_rand_decimal(3, 2) n2 = gen_rand_decimal(3, 1) if n1 < n2: tmp = n1 n1 = n2 n2 = tmp ans = n1 - n2 q = question(None, f'{n1} - {n2} =', f'{ans}', 'decimal', level, 'Express your answer in Decimal') return q
def integer_minus(): n1 = gen_rand_int(randint(1, 5)) n2 = gen_rand_int(randint(1, 5)) if n1 < n2: tmp = n1 n1 = n2 n2 = tmp ans = n1 - n2 q = question(None, f'{n1} - {n2} =', f'{ans}', 'int', level, 'Express your answer in number') return q
def gen_rand_fraction_equation(p): (eq,ans) = recur_gen_rand_fraction_equation(p) print(f'eq={eq}') #ans = eval(eq) q = question(None, f'{eq}=', f'{ans}', 'fraction', 5, 'Express your answer in Simplified Fraction') return q
def gen_rand_equation(p): eq = recur_gen_rand_equation(p) ans = round(eval(eq),8) ans_in_decimal = Decimal(f'{ans}') q = question(None, f'{eq}=', f'{ans_in_decimal}', 'decimal', 5, 'Express your answer in Decimal') return q