+ 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

19th Jan 2019, 1:13 AM
Dinis Bento
Dinis Bento - avatar
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
19th Jan 2019, 3:08 AM
Diego
Diego - avatar
19th Jan 2019, 5:39 AM
Louis
Louis - avatar
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?
19th Jan 2019, 3:54 PM
Dinis Bento
Dinis Bento - avatar