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 format:
(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
Code:
import math
PI = math.pi
E = math.e
print \"pi=%.1f, e=%.1f\"%(PI,E)
print \"pi=%.2f, e=%.2f\"%(PI,E)
print \"pi=%e, e=%e\"%(PI,E)
print \"pi=%.5f, e=%.5f\"%(PI,E)
Output:
pi=3.1, e=2.7
pi=3.14, e=2.72
pi=3.141593e+00, e=2.718282e+00
pi=3.14159, e=2.71828
