table of powers using string methods : str « Buildin Function « Python Tutorial






x = 'x'
y = 'x**2'
z = 'x**x'
print x, y.rjust(4), z.rjust(6)
print "=" * 14
for n in range(1,6):
    nn = str(n**2)
    nnn = str(n**n)
    print n, nn.rjust(4), nnn.rjust(6)








13.44.str
13.44.1.str function coerces data into a string
13.44.2.str() and repr()
13.44.3.How to Create and Assign Strings
13.44.4.table of powers using string methods