Question #314145

Write a program that prints the value of 120.456789 rounded to the nearest digit, tenth, hundredth, thousandth, and ten-thousandth. [Hint: This should make use of formatted output.].


Expert's answer

num = 120.456789
for i in range(5):
    print(f'{num:0.{i}f}')
LATEST TUTORIALS
APPROVED BY CLIENTS