#
# Author: Michele Van Dyne
# Demonstrates formatted printing with floating point numbers
#
import math
f = 0.123456789
# %f code is used with floating point variables
# %f defaults to rounding to 6 decimal places
# \n prints a newline character
print("f is about %f\n" %(f))
# Number of decimal places specified by .X
# Output is rounded to that number of places
print("PI is about %.1f\n" %(math.pi))
print("PI is about %.2f\n" %(math.pi))
print("PI is about %.3f\n" %(math.pi))
print("PI is about %.4f\n" %(math.pi))
# %e code outputs in scientific notation
# .X specifies number of significant figures
C = 299792458.0
print("speed of light = %e\n" %(C))
print("speed of light = %.3e\n" %(C))