You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

11 lines
287 B
Python

import fractions
import math
print('PI =', math.pi)
f_pi = fractions.Fraction(str(math.pi))
print('No limit =', f_pi)
for d in [1, 5, 50, 90, 100, 500, 1000000]:
limited = f_pi.limit_denominator(d)
print('{0:8} = {1}'.format(d, limited))