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!

This biggest issue I can’t solve is forcing the output to display the hundreds place value when happens to be a 0. The most obvious application of this would be in displaying currency values. This has been confusing my newer students who are puzzled when I’m like "if there’s only one digit after the decimal point, add a zero. It’s a cool natural lesson LOL but overall it’s just annoying.

Please help! Here is my code:

a = numericValue(“\operatorname{round}(${r.float(2,4)},2)”)

It’s been so long since I worked on activities involving percent application that I can’t remember who to credit for this workaround, but I think this is what you are looking for?


Format = 


#This checks to see if the rounded values a0, a1 & a2 would ever display in the same way. 
#For whole numbers a0=a1 and a1=a2 so you manually add 2 zeros
#For numbers with a non zero first dp and a zero in the second dp a1=a2 so you manually add a zero to the content

money= when a0=a1 and a1=a2  "${a0}.00"
when a1=a2 "${a1}0"
otherwise "${a2}"
1 Like