Taking Math Input an rounding it to 2 decimal places to use in CL text

I am trying to give students feedback in an activity through CL text. Some of the questions require that students input their answers as fractions, but I want to limit my feedback ouput to just 4 decimal places. How can I code this?

Here is an example of my code:

content: “{question} {feedback}” (note: missing strings are really there in the code)

question = "A recent survey of American adults found that 638 of 840 have a favorable opinion of the current presidential administration. Develop a confidence interval for the actual proportion of American adults that have a favorable opinion of the administration.

What is the sample proportion \hat{p}?"

answerlow = 0.75
answerhigh = 0.761

feedback =
when Input21.submitted and Input21.numericValue< answerhigh and Input21.numericValue> answerlow “\n\n\n✅Good job. ${Input21.numericValue} is correct.”

when Input21.submitted “\n\n\n❌ Nope. Remember, we are now looking for a sample proportion. This is simply the number of adults who approve of the president divided by the number that were asked.”
otherwise “”

I want the output for the correct answer “\n\n\n✅Good job. ${Input21.numericValue} is correct.” to be limited to a certain number of decimal places (in this case 3). How can I make this happen?

Thanks in advance.

In the Note CL, you can round defined constant numbers, your numbers, or input like this:

n1 = numericValue(`\round(\pi,2)`)
n2 = numericValue(`\round(.0123456,4)`)
n3 = numericValue(`\round(${Input21.numericValue},4)`) 
content: "this is ${n1}   \nand this is another number: ${n2}   \nand for 638/840: ${n3}"

And it will look like this:

1 Like

Thanks. That works like a champ!