## Digits of PI (Part 1)

**Problem**

You want to work with the digits of PI. Why? For instance you want a new job (screenshot here if it got removed since then).

**Solution**

I like simple solutions. So instead of generating the digits, I simply fetched the data from the web. This is a fast, efficient, and painless approach of the problem :) Visit http://newton.ex.ac.uk/research/qsystems/collabs/pi/, where you can download several data files.

**For the lazy pigs**

I made a script that downloads the data, parses them, and returns the digits as a string. Here it is.

Usage (get the first 30 digits of PI after the dot):

#!/usr/bin/env python from jabbapylib.math import pi def main(): digits = pi.get_digits_of(pi.PI3) # get 10^3 = 1000 digits print digits[:30] if __name__ == "__main__": main()

Output:

141592653589793238462643383279

jabbapylib is here

Categories: python
digits of pi, pi

Comments (0)
Trackbacks (0)
Leave a comment
Trackback