You are viewing a single comment's thread. Return to all comments →
import math print 'The value of {label} is approximately {0:.3f}.'.format(math.pi, label='PI')
output: "The value of PI is approximately 3.142."
There are several more examples of str.format here: Python 2 Input & Output
Seems like cookies are disabled on this browser, please enable them to open this website
Arithmetic Operators
You are viewing a single comment's thread. Return to all comments →
output: "The value of PI is approximately 3.142."
There are several more examples of str.format here: Python 2 Input & Output