Write Python statements that print the values of pi and the
Write Python statements that print the values of pi and the Euler constant e in the shown formats. (a) pi - 3.1, e = 2.7 (b) pi = 3.14, e = 2.72 (C) pi - 3.141593e+00, e = 2.718282e=00 (d) pi = 3.14159, e = 2.71828
Solution
import math
format(math.pi, \'0.1f\')
format(math.pi, \'0.2f\')
format(math.pi, \'0.5f\')
format(math.e, \'0.1f\')
format(math.e, \'0.2f\')
format(math.e, \'0.5f\')
For (c) you have to declare
pi=math.pi
print \"%.6e\" % pi
e=math.e
print \"%.6e\" % e
