Round to Two Decimal Places
Then the closing curly brace and a quote to close the f-string. So when you print it now, then you have the
98.60, which is exactly what you want. With the correct result in place, have a closer look at the content of the f-string, or more specifically what’s inside the curly braces.
So that’s what you do with the
.2f. This specifies the precision of the number when it’s displayed. So in this case, it’s saying that you want two digits after the decimal point. You can, for example, change a
2 to a
4, and when you run the code, you can see that now the
temp_far variable has four digits after the zero. It’s
02:37 So you display all converted temperatures rounded to two decimal places. That means the third part of this part is done, and what’s left now is prompting the user, and that’s what you will do in the next lesson.
Become a Member to join the conversation.