Boston Python Workshop 3/Friday/Tutorial: Difference between revisions

no edit summary
imported>Jesstess
imported>Jesstess
No edit summary
Line 67:
 
The two previous expressions produce the same result. You only need to make one of the numbers in each fraction have a decimal. When the Python interpreter goes to do the division, it notices that one of the numbers in the fraction cares about decimals and says 'that means I have to make the other number care about decimals too.
 
===Modulus===
 
The modulus operator <code>%</code> gives you the remainder after division. For example, 6 % 3 returns 0 because 3 goes into 6 twice, with nothing left over. 5 % 3 returns 2, because 3 goes into 5 once, with 2 left over.
 
<pre>
10 % 2
10 % 3
10 % 4
10 % 5
</pre>
 
==Types==
Anonymous user