Pi as student input

What is the code for allowing students to enter the letters “pi” ?

If students type “pi” in a math input, it will turn into π, just like it does in the Desmos calculator. If you want them to write pi but not have it turn into “pi”, then I’d use a text input instead. More information about what you’re trying to do would be helpful.

1 Like

I would like to use a prompt that recognizes pi so that if a student enters only an approximation, 3.14 it gives “INCORRECT” and when the student enters “pi” gives “CORRECT”.

Thank you

1 Like

I don’t think you’ll be able to reliably distinguish between students typing pi and them typing in lots of pi correct to a large number of decimal places.

Or you could do something a little risky with some code like this

correct: this.latex = "\\pi"

But this is not very robust because if they put in spaces or even type “pi + 0” it will fail.

1 Like

Using “\pi\” still gives an error message (see below)

1 Like

I don’t have a complete solution, but I’ve seen things in the graphing area where you use round to test for accuracy to a certain number of decimal places.
In the graphing area, I think the formula looks something like this: round(10^6*(answer-pi))/(10^6)
And then this conversation mentions using functions in CL to evaluate.
Maybe combining those strategies together in CL would work for you?

simple function evaluated with multiple values