How to keep the number fraction format in Python3.x while performing simple operations?
<p>In code, I would like to keep the format of number while doing different simple operations (e.g. multiplication  1/6 * 1/6 ) in python 3.x. </p>

<p>I want to have:</p>

<pre><code>{
    2: 1/36,
    3: 2/36,
    4: 3/36,
    5: 4/36,
    6: 5/36,
    7: 6/36,
    8: 5/36,
    9: 4/36,
    10: 3/36,
    11: 2/36,
    12: 1/36
}
</code></pre>

<p>but i get this:</p>

<pre><code>{
    2: 0.027777777777777776,
    3: 0.05555555555555555,
    4: 0.08333333333333333,
    5: 0.1111111111111111,
    6: 0.1388888888888889,
    7: 0.16666666666666669,
    8: 0.1388888888888889,
    9: 0.1111111111111111,
    10: 0.08333333333333333,
    11: 0.05555555555555555,
    12: 0.027777777777777776
}
</code></pre>

<p>Any suggestions?</p>

<p>I'm not aware of any programming language <strong>not</strong> evaluating the expression to a float without mentioning.</p>

<p>In case of python you should use module <a href="https://docs.python.org/3/library/fractions.html?highlight=fraction#module-fractions" rel="nofollow">fraction</a>.</p>

python