Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

how do I round a number to two decimal places in python 3 without using .2f?

+1 vote
asked 6 days ago by Matthew Kim (130 points)
The instructors says we can round it, but how do I do that without using .2f? (I'm not supposed to use .2f yet)

2 Answers

0 votes
answered 4 days ago by Peter Minarik (54,560 points)

This article should help. Use the round() function.

x = round(5.76543, 2)
print(x)
0 votes
answered 2 days ago by Tegah D Oweh (140 points)
x = 5.85629
print(x)
x = x * 100
x = round(x, 0)
x = x / 100
print(x)
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...