As a beginner in Python and I stumbled upon a seemingly simple code that I can't make to work.
I'm trying to print an output of calculation with 1 decimal number, this is one of the versions of the code I tried. I also tried using format(x/s, '.1f')
, but neither of those worked.
There is part of my code:
for v in range(n):
#It will repeat the calculation the many times its defined in n input
x = R*(v*n)
if x/s*100<100:
print("meridian will be", '%.1f' % x/s*100, "cm from center")
else x/s*100>100:
print("meridian will be - cm from center")
Using '%.1f'
seems to have no effect, is the syntax wrong? I'm really not sure...