Random Decimal Generator

I am wanting to code my note to where students can add two separate decimals, and I want them to be able to answer a series of these in one desmos slide. I know the code:
r =randomGenerator()
a = r.float(0,100)
b = r.float(0,100)

However, I want the decimals to be between one to three decimal places.

This takes your floating value and rounds to 3 decimal places.

a = numericValue("\operatorname{round}(${r.float(0,100)},3)")
1 Like

This did not work when I tried it. In the notes (in the student preview) it is displaying “\operatorname{round}[decimal here],3”

Then, when I put the numericValue in front of that, in the student preview, it said “undefined”

Did you make sure to include the r=randomGenerator() part?

Yes I did! I am wondering if I should put r.int instead of r.float?

Are you missing the parentheses around [decimal here],3?

I’m trying to do something similar - generate small random numbers for students to write in scientific notation. I thought the rounding might eliminate some of the digits, but it’s not working. Here’s the code I’m using:
r = randomGenerator(button.pressCount)
a = r.float(0,0.1)
rounded_value=numericValue("\\round(${a},5)") content: "${a}"

Your content is the unrounded “a”. Try using “rounded_value” instead.

Yes, it worked beautifully. Thank you, so much!