I looked on YouTube and was able to figure out how to create problems with the random generator, but I cannot figure out how to get it to use mixed numbers. How can I do this? This is the code I am using:
r = randomGenerator(refresh1.pressCount)
addend1 = r.int(0,100)
addend2 = r.int(0,100)
sum = numericValue(“{addend1}+{addend2}”)
numberList(C_{orrectnessHistory}
): mathinput1.history(“correct”)
Instead of .int()
you can use .float()
to get decimal values to 15 places. You could round them using numericValue.
addend1 = numericValue(`\round(${r.float(0,100)},2)`)
If you’re looking to display a mixed number, you’d need to randomly generate each part of the mixed number separately.
r = randomGenerator()
denom0 = r.int(2,10)
numerator0 = r.int(1,numericValue(`${denom0}-1`))
gcf = numericValue(`\gcf(${denom0},${numerator0})`)
#use below for simplified fractions
denom = numericValue(`${denom0}/${gcf}`)
numer = numericValue(`${numerator0}/${gcf}`)
whole = r.int(1,10)
fracLatex = `${whole}\frac{${numer}}{${denom}}`