<br><br><div class="gmail_quote">On Wed, Aug 31, 2011 at 3:58 PM, Hugo Arts <span dir="ltr">&lt;<a href="mailto:hugo.yoshi@gmail.com">hugo.yoshi@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Wed, Aug 31, 2011 at 9:35 PM, Lisi &lt;<a href="mailto:lisi.reisz@gmail.com">lisi.reisz@gmail.com</a>&gt; wrote:<br>
&gt; ??  If either n or x or both were 0, and % were the same thing as *, the<br>
&gt; statement would be true, but from the context I don&#39;t think that % does mean<br>
&gt; the same as *, because * appears very soon after in the same fragment of<br>
&gt; code.<br>
&gt;<br>
&gt; Lisi<br>
&gt;<br>
&gt; I&#39;m sorry I am making such heavy weather of all this.  Blame 2 things: anno<br>
&gt; domini and an exaggerated (obsessive) need to understand language.<br>
<br>
</div>% is the remainder operator:<br>
<br>
<a href="http://docs.python.org/library/stdtypes.html#numeric-types-int-float-long-complex" target="_blank">http://docs.python.org/library/stdtypes.html#numeric-types-int-float-long-complex</a><br>
<br>
it is how much remains after you perform an integer division, e.g. 23<br>
% 5 == 3, since 20 / 5 == 4 and then you are left with 3.<br>
<br>
 n % y == 0 if n is divisible by y. This is useful in factoring prime<br>
numbers, and in the case of y == 2, for checking if the number n is<br>
even.<br>
<font color="#888888"><br>
Hugo<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
Tutor maillist  -  <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br></div></div></blockquote><div><br>Here is a little example that shows how using the &#39;mod&#39; or &#39;modulus&#39; operator can select only values that are divisible by 3. <br>
</div></div><br>&gt;&gt;&gt; for i in range(16):<br>...     if not i % 3:<br>...       print i<br>... <br>0<br>3<br>6<br>9<br>12<br>15<br><br clear="all"><br>-- <br>Joel Goldstick<br><br>