# Numeric Answers - PGML

Jump to navigation
Jump to search

## Numeric Answer Checkers

To use a number as an answer, just put the number in braces after the answer blank:

BEGIN_PGML The value of [: 3 + 5 :] is [______]{8} END_PGML

The value can be stored in a variable:

$a = 3; $b = 5; $answer = $a + $b; BEGIN_PGML The value of [: [$a] + [$b] :] is [______]{$answer} END_PGML

or it can be an expression producing the value:

$a = 3; $b = 5; BEGIN_PGML The value of [: [$a] + [$b] :] is [______]{$a+$b} END_PGML

The number can be a MathObject Real or Complex, or Fraction, or other numeric value as well

$a = 3; $b = 5; $answer = Compute("$a + $b"); BEGIN_PGML The value of [: [$a] + [$b] :] is [______]{$answer} END_PGML

It is also possible to put the number (or formula leading to the number) in quotation marks, though this isn't necessary. If you do, however, the correct answer will be shown as the formula you used rather than the numeric value itself.

$a = 3; $b = 5;

BEGIN_PGML The value of [: [$a] + [$b] :] is [______]{"$a + $b"} END_PGML

will show "3 + 5" as the correct answer, not 8. (**Note:** this requires a recent version of PGML.pl)

See the section on MathObject Answers for details on how to provide additional control over the MathObject answer checkers.