In [1]:
name = "Mike"
age = 45
salary = 15.75
In [2]:
# string formatting
print("Hello there %s. How are you? " % (name))
In [3]:
# formatting redux
print("%s makes %f per hour." % (name, salary))
In [6]:
# let's use spacing
print("%s makes %.2f per hour." % (name, salary))
In [7]:
# right alignment
print("-" * 10) # print 10 dashes
print("%10d" %(age))
In [8]:
# left alignment
print("-" * 10)
print("%-10d" % (age))
In [ ]: