This shows how to find two integer values whose ratio approximates the mathematical constant, pi, somewhat accurately.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ```
from __future__ import print_function
import math
ratio = math.pi.as_integer_ratio()
# It can be verified with:
print(ratio[0] / ratio[1]) # for Python 3.x
# or
print(1.0 * ratio[0] / ratio[1]) # for Python 2.7x
# It gives:
# 3.141592653589793
# which is the value of pi to some decimal places.
``` |

More details here:

http://jugad2.blogspot.in/2016/06/a-pythonic-ratio-for-pi-or-py-for-pi.html