+ 1
How can you increase the number of decimals output by a float in python?
I want to print pi for as long as i can, but i can only output 16 decimal numbers, no matter what https://code.sololearn.com/cs6kNU8Km5c1/?ref=app
3 Respostas
+ 4
You can use f-strings for that. For example (line 9):
print(f"{pi:.16f}")
# prints 16 digits after decimal point
print(f"{pi:.20f}")
# prints 20 digits after decimal point
+ 4
From:https://stackoverflow.com/questions/45416626/print-pi-to-a-number-of-decimal-places-JUMP_LINK__&&__python__&&__JUMP_LINK
To do better, we have to calculate PI ourselves -- using a series evaluation is one approach
https://code.sololearn.com/cRuCv0E8SGu6/?ref=app
0
Thanks guys, I followed diego advice, now i can output 51 characters, louis how can i adapt your advice in a manner i don'r have to use import?