# [LON-CAPA-users] Illegal division by zero

Bob Gonzales rgonzal at binghamton.edu
Fri May 29 12:21:40 EDT 2015

```Rex,

Here's the code, I thought it might be easier to cut and paste it in
construction space to make it easier to debug.  The problem works fine for
me in construction space.   One student with \$f1=1.0 and one student with
\$f1=6.0221e23 have gotten it correct so far.

<problem>
<part id="t06p12a">
<script type="loncapa/perl">
\$n1=&random(0.025,0.050,0.001);
\$t1=&random(1,2);
\$unit1=&choose(\$t1,"moles","molecules");
\$f1=&choose(\$t1,1.00,6.0221e23);
\$mw1=(12.011*20.0)+(1.008*24.0)+(15.999*2.0);
\$ansa= \$n1 * 1e-3 * \$f1/ \$mw1;
</script>

<startouttext />
<p>A particular oral contraceptive contains &format(\$n1,'3f') mg of ethinyl
in each pill. The formula of this compound is <chem>C20H24O2</chem>.
How many \$unit1 of ethinyl estradiol are there in one pill?  (give answer
to 3 digits)</p>
<endouttext />
<responseparam name="tol" type="tolerance" default="5%"
description="Numerical Tolerance" />
<responseparam name="sig" type="int_range,0-16" default="3,4"
description="Significant Figures" />
<textline />
<hintgroup>
<startouttext /><endouttext />
</hintgroup>
</numericalresponse>
</part>
<part id="t06p12b">
<script type="loncapa/perl">
\$t2=&random(1,3);
\$sub2=&choose(\$t2,"carbon","hydrogen","oxygen");
\$f2=&choose(\$t2,20.0,24.0,2.0);
\$ansb=(\$ansa/\$f1)* \$f2 * 6.0221e23;
</script>

<startouttext />
<p>How many \$sub2 atoms are there in one of these pills (due to the
presence

<endouttext />
<responseparam name="tol" type="tolerance" default="5%"
description="Numerical Tolerance" />
<responseparam name="sig" type="int_range,0-16" default="3,4"
description="Significant Figures" />
<textline />
<hintgroup>
<startouttext /><endouttext />
</hintgroup>
</numericalresponse>
</part>

<part id="t06p12c">
<script type="loncapa/perl">
\$mw3=&choose(\$t2,12.011,1.008,15.999);
\$ansc=\$ansb*\$mw3/6.0221e23;
</script>

<startouttext />
<p>What mass of \$sub2 is this? (Enter the answer in grams.)</p>

<endouttext />
<responseparam name="tol" type="tolerance" default="5%"
description="Numerical Tolerance" />
<responseparam name="sig" type="int_range,0-16" default="3,4"
description="Significant Figures" />
<textline />
<hintgroup>
<startouttext /><endouttext />
</hintgroup>
</numericalresponse>
</part>
</problem>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.lon-capa.org/pipermail/lon-capa-users/attachments/20150529/b0d6cdaa/attachment.html>
```