why can't my code keep three significant digits | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 2

why can't my code keep three significant digits

the code (input): a = input('please entet a integer :') s = pow(eval(a),0.5) print('{:3f}'.format(s)) when I input 36 my code output 6.000000. why dose it have six 0? it output3.162278 when I input 10.why did my code didn't work. then I had changed the code, I used the round function, however, it still was a bit comfusing. the code (input): a = input('please enter a integer:') s = pow(eval(a),0.5) p = round(s,3) print(p) when I input 36, it output 6.0. however, it output 3.162 if I input 10

9th Apr 2019, 12:32 AM
Henry&kelly
Henry&kelly - avatar
1 Respuesta
+ 4
There should be a point before "3f". Also, it's better if you use int() instead of eval(). a = int(input()) s = pow(a,0.5) print('{:.3f}'.format(s))
9th Apr 2019, 12:50 AM
Diego
Diego - avatar