This is romantic! So listen up! A 3D heart shape may be drawn using the following implicit function: Or, in Python: def heart_3d(x,y,z): return (x**2+(9/4)*y**2+z**2-1)**3-x**2*z**3-(9/80)*y**2*z**3 Trouble is, there is no direct way of graphing implicit functions in Python. But anything can be found on Stack Overflow. Putting it all together: #!/usr/bin/env python from mpl_toolkits.mplot3d import […]
π approximation script, from Stephen Chappell. import sys def pi(): a, b, c, d, e, f = 1, 0, 1, 1, 3, 3 while True: if a * 4 + b – c < c * e: yield e a, b, c, d, e, f = a * 10, (b – c * e) * […]