forked from openwebwork/webwork2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbad_input.pg
108 lines (87 loc) · 3.31 KB
/
bad_input.pg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
##DESCRIPTION
## A very simple first problem
##ENDDESCRIPTION
##KEYWORDS('algebra')
DOCUMENT(); # This should be the first executable line in the problem.
loadMacros(
"PG.pl",
"PGbasicmacros.pl",
"PGchoicemacros.pl",
"PGanswermacros.pl",
"PGauxiliaryFunctions.pl"
);
TEXT(&beginproblem);
$showPartialCorrectAnswers = 1;
$a = random(-10,-1,1);
$b = random(1,11,1);
$c = random(1,11,1);
$d = random(1,11,1);
=123;
#warn "foobar";
#DEBUG_MESSAGE("this is a debuggin message.");
#WARN_MESSAGE("this is a warning message.");
BEGIN_TEXT
$PAR
displayMode is $displayMode $BR
$PAR
This problem demonstrates how you enter numerical answers into WeBWorK. $PAR
Evaluate the expression \(3($a )($b -$c -2($d ))\):
\{ ans_rule(10) \}
$BR
END_TEXT
$ans = 3*($a)*($b-$c-2*($d));
&ANS(strict_num_cmp($ans));
BEGIN_TEXT
In the case above you need to enter a number, since we're testing whether you can multiply
out these numbers. (You can use a calculator if you want.)
$PAR
For most problems, you will be able to get WeBWorK to
do some of the work for you. For example
$BR
Calculate ($a) * ($b): \{ ans_rule()\}
$BR
END_TEXT
$ans = $a*$b;
&ANS(std_num_cmp($ans));
BEGIN_TEXT
The asterisk is what most computers use to denote multiplication and you can use this with WeBWorK.
But WeBWorK will also allow use to use a space to denote multiplication.
You can either \($a * $b\) or \{$a*$b\} or even \($a \ $b\). All will work. Try them.
$PAR
Now try calculating the sine of 45 degrees ( that's sine of pi over 4 in radians
and numerically sin(pi/4) equals \{1/sqrt(2)\} or, more precisely, \(1/\sqrt{2} \) ).
You can enter this as sin(pi/4) , as
sin(3.1415926/4), as 1/sqrt(2), as 2**(-.5), etc. This is because WeBWorK knows about
functions like sin and sqrt (square root). (Note: exponents
can be indicated by either a "caret" or **). Try it.$BR \( \sin(\pi/4) = \) \{ ans_rule(20) \}$PAR
Here's the
\{
htmlLink(qq!http://webwork.math.rochester.edu/webwork_system_html/docs/docs/pglanguage/availablefunctions.html!,"list
of the functions") \}
which WeBWorK understands. WeBWorK ALWAYS uses radian mode for trig functions.
$PAR
END_TEXT
&ANS( std_num_cmp(sin(3.1415926/4)) );
BEGIN_TEXT
You can also use juxtaposition to denote multiplication. E.g. enter \( 2\sin(3\pi/2) \).
You can enter this as 2*sin(3*pi/2) or more simply as 2sin(3pi/2). Try it: $BR
\{ ans_rule(20) \}$PAR
END_TEXT
$pi = 4*atan(1);
&ANS( std_num_cmp(2*sin(3*$pi/2)) );
BEGIN_TEXT
Sometimes you need to use ( )'s to make your meaning clear. E.g. 1/2+3 is 3.5, but 1/(2+3) is .2 Why?
Try entering both and use the ${LQ}Preview${RQ} button below to see the difference. In addition to
( )'s, you can also use [ ]'s and $LB ${RB}'s. $BR
\{ ans_rule(20) \}$PAR
END_TEXT
&ANS( std_num_cmp(.2));
BEGIN_TEXT
You can always try to enter answers and let WeBWorK do the calculating.
WeBWorK will tell you if the problem requires a strict numerical answer.
The way we use WeBWorK in this class there is no penalty for getting an answer wrong. What counts
is that you get the answer right eventually (before the due date). For complicated answers,
you should use the ${LQ}Preview${RQ} button to check for syntax errors and also to check that the answer
you enter is really what you think it is.
END_TEXT
ENDDOCUMENT(); # This should be the last executable line in the problem.