+ 1

# Python compiling pi

I would like to calculate a designated amount of decimals, how can i store more digits of pi? https://code.sololearn.com/cTl17VzAax5x/?ref=app

3 Answers

+ 3

You can use f-strings for that. For example (line 6):
print(f"{pia:.16f}")
# prints 16 digits after decimal point
print(f"{pia:.20f}")
# prints 20 digits after decimal point

0

The Python standard library has a decimal module for arbitrary precision arithmetic. The documentation of that module has an example of a pi calculator using the module so you can build on that.