Answer to Question #314145 in Python for junior

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.].


1
Expert's answer
2022-03-20T06:21:00-0400
num = 120.456789
for i in range(5):
    print(f'{num:0.{i}f}')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS