## Forum archive 2000-2006

### Michael Gage - True false example

by Arnold Pizer -
Number of replies: 0
 True false example topic started 5/8/2000; 8:08:41 PMlast post 5/8/2000; 8:08:41 PM
Michael Gage - True false example
5/8/2000; 8:08:41 PM (reads: 3686, responses: 0)

## The true false basic example

(for more advanced information on select lists, see Select.pm) To obtain this problem

(1 pt) rochesterLibrary/setMAAtutorial/truefalseexample.pg
 True False Example Enter T or F depending on whether the statement is true or false. (You must enter T or F -- True and False will not work.)  1. All differentiable strictly increasing functions have non-negative derivatives at every point 2. All polynomials are differentiable. 3. All compact sets are closed 4. All closed sets are compact

WARNINGS
µ¦å{h­
DOCUMENT();      loadMacros("PGbasicmacros.pl",           "PGchoicemacros.pl",           "PGanswermacros.pl",);TEXT(beginproblem(), $BR,$BBOLD, "True False Example", $EBOLD,$BR,$BR);# Since this is a true questions, we do not usually wish to tell students which# parts of the matching question have been answered correctly and which are# incorrect. That is too easy. To accomplish this we set the following flag to# zero.$showPartialCorrectAnswers = 0;# True false questions are a special case of a "select list"# Make a new select list$tf = new_select_list();#$tf now "contains" the select list object.# Insert some  questions and whether or not they are true.$tf -> qa ( # each entry has to end with a comma"All continuous functions are differentiable.","F","All differentiable functions are continuous.","T","All polynomials are differentiable.","T","All functions with positive derivatives are increasing.","T","All compact sets are closed","T","All closed sets are compact","F","All increasing functions have positive deriviatives","F","All differentiable strictly increasing functions have non-negative derivatives at every point","T",); # Choose four of the question and answer pairs at random.$tf ->choose(4);# Now print the text using $ml->print_q for the questions# and$ml->print_a to print the answers.BEGIN_TEXT$PAREnter T or F depending on whether the statement is true or false.(You must enter T or F -- True and False will not work.)$BR\{ $tf-> print_q \}$PAREND_TEXT# Enter the correct answers to be checked against the answers to the students.ANS(str_cmp( $tf->ra_correct_ans ) ) ;ENDDOCUMENT(); # This should be the last executable line in the problem. <!-- (1 pt) Enter T or F depending on whether the statement is true or false. (You must enter T or F -- True and False will not work.) 1. All continuous functions are differentiable. 2. All polynomials are differentiable. Enter this code 1 DOCUMENT(); # This should be the first executable line in the problem.2 loadMacros(PG.pl,3 PGbasicmacros.pl,4 PGchoicemacros.pl,5 PGanswermacros.pl,6 PGgraphmacros.pl,7 );8 9 10 TEXT(beginproblem()); # standard preamble to each problem.11 # Since this is a true questions, we do not usually wish to tell students which12 # parts of the matching question have been answered correctly and which are13 # incorrect. That is too easy. To accomplish this we set the following flag to zero.14$showPartialCorrectAnswers = 0;1516      # Make a new select list17      $tf = new_select_list();18 #$tf now "contains" the select list object.  19      # See matchinglistexample.pg for details2021      # Insert some  questions and whether or not they are true.22      $tf -> qa (23 "All continuous functions are differentiable.", # each entry has to end with a comma24 "F",25 "All differentiable functions are continuous.",26 "T",27 "All polynomials are differentiable.",28 "T",29 "All functions with positive derivatives are increasing.",30 "T"31 ); # remember every statement has to end with a semi-colon.3233 # Choose two of the question and answer pairs at random.34$tf ->choose(2);  35      # Now print the text using $ml->print_q 3637 BEGIN_TEXT38$PAR3940      Enter T or F depending on whether the statement is true or false.41      (You must enter T or F -- True and False will not work.)$BR42 \{$tf-> print_q \}43      $PAR44 END_TEXT45 46 # Enter the correct answers to be checked against the answers to the students.47 ANS( str_cmp($tf->ra_correct_ans )   ) ;4849      # The ra_... means that the output of this function is an array reference -- a gadget that looks like50      # [T, F, T] or whatever the list of T's and F's represents the correct answers. 51      # That's it.52      ENDDOCUMENT();        # This should be the last executable line in the problem.
-->

2. First we create the object -- this time called a "select list". $tf = new_select_list(); (line 17) 3. Next we enter a list of questions, followed by their answers (T or F) (lines 22 - 31) 4. Choose two questions at random from the list. $tf ->choose(2); (line 34)
5. Print the questions  { $tf-> print_q }  (line 42) 6. Register the correct answers  ANS( str_cmp($tf->ra_correct_ans ) ) ;  (line 47)