print with format in python code example
Example 1: python text fromatting rows
table_data = [
['a', 'b', 'c'],
['aaaaaaaaaa', 'b', 'c'],
['a', 'bbbbbbbbbb', 'c']
]
for row in table_data:
print("{: >20} {: >20} {: >20}".format(*row))
Example 2: python format numeric output
for x in numbers:
print "{:10.4f}".format(x)
prints
23.2300
0.1233
1.0000
4.2230
9887.2000
Example 3: python print format
print(f'I love {Geeks} from {Portal}')
Example 4: print format python
print('{:0.3f} {:0.3f}'.format(y, z))
Example 5: python print format
'{:10.5}'.format('xylophone')