CodeX
Published in

CodeX

Approximating Pi (π) using Python & Some Math

Some Apple Lattice Pie

We’ve all probably learnt about pi (π) in school at some point in our lives, and know it as the irrational mathematical constant 3.14159......, which is defined as the ratio of a circle’s circumference to its diameter. While we can simply get pi using Python’s math module:

import math
pi = math.pi # and we get 3.14159......

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Liu Zuo Lin

Liu Zuo Lin

Software Engineer, Python Tutor, Tech Writer. My Free Ebooks — 1) Python Zero To One 2) 40 Python Practice Questions For Beginners — https://zlliu.co/books