+ 1

Problem with digits of Pi

My code fail in test case 4&5,why? https://code.sololearn.com/cxoR0j81Lk6o/?ref=app

12th Jul 2020, 2:55 PM
Lewin S
Lewin S - avatar
4 Answers
+ 7
The precission of math.pi is not suitable for this task. It only shows 15 decimal places. Try to find an other way to get the required precission. Remember that input format is defined as: 0<N<1000
12th Jul 2020, 3:24 PM
Lothar
Lothar - avatar
+ 8
ok - no problem. An other way would be to use the mpmath library, which is also avaible in playground. With .dps you can set the precission to a defined length: from mpmath import mp mp.dps = 100 print(str(mp.pi))
12th Jul 2020, 3:47 PM
Lothar
Lothar - avatar
+ 3
I solved the problem.You just have to copy 1000digits fron the web and paste it in the code😂
12th Jul 2020, 3:30 PM
Lewin S
Lewin S - avatar
0
This was the only code coach challenge I haven't solved for python and after all sorts of ways I ended up just getting the 1000 digits off a website and creating a string!! Feels like cheating!!! I tried the BBP formula to get nth digit but got no where with that!!!
24th Jul 2020, 8:21 PM
Eoin