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.
Login
Login
OnlineGDB Q&A
Questions
Unanswered
Tags
Ask a Question
Ask a Question
how do I round a number to two decimal places in python 3 without using .2f?
+3
votes
asked
Jun 19, 2022
by
Matthew Kim
(
150
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)
python-3
want-help
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
2 Answers
0
votes
answered
Jun 20, 2022
by
Peter Minarik
(
78,090
points)
This
article should help. Use the
round()
function.
x = round(5.76543, 2) print(x)
commented
Jun 27, 2022
by
Matthew Kim
(
150
points)
thanks so much!
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
0
votes
answered
Jun 22, 2022
by
Tegah D Oweh
(
140
points)
x = 5.85629
print(x)
x = x * 100
x = round(x, 0)
x = x / 100
print(x)
commented
Jun 27, 2022
by
Matthew Kim
(
150
points)
thanks a lot!
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
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.
...