Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.


+5 votes
asked in CSC201 Spring 2021 by (1 point)

2 Answers

+3 votes

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

answered by (1 point)
+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 (1 point)