What do you want to save?
Add Code snippet
New code examples
-
Python 2021-11-05 02:53:14
algorithms for calculating pi in python
from decimal import * #Sets decimal to 25 digits of precision getcontext().prec = 25 def factorial(n): if n<1: return 1 else: return n * factorial(n-1) def plouffBig(n): #http://en.wikipedia.org/wiki/Bailey%E2%80%93Borwein%E2... Add solution -
Python 2021-10-06 12:24:02
how to lag python
Evil! Anyway... print(9**9) is easily manageable for python. On a faily fast computer, it will only take a few milliseconds for the output to appear: 387420489. Check it against a calculator. Not bad. So let's punish our interpreter properly. print(9*... Add solution -
Python 2021-09-24 12:41:04
high precision, decimal, float, mpmath
#!/usr/bin/python from decimal import Decimal, getcontext import math import mpmath getcontext().prec = 50 mpmath.mp.dps = 50 num = Decimal(1) / Decimal(7) num2 = mpmath.mpf(1) / mpmath.mpf(7) print(" math.sqrt: {0}".format(Decimal(math.s... Add solution