Welcome to the CSC Q&A.
Get help and give help!
Write great code!
It is our choices... that show what we truly are, far more than our abilities.


+5 votes
asked in CSC201 Spring 2021 by (8 points)

2 Answers

+3 votes

use an f string. the parameter for fixed decimal places is ._f. so something like

answered by (8 points)
+2 votes

One way to do it is to use a format statement:

'{:.3f}'.format(variable) will always display three digits after the decimal.

answered by (337 points)