print a formatted table using python

Solutions on MaxInterview for print a formatted table using python by the best coders in the world

showing results for - "print a formatted table using python"
Fabio
25 Feb 2018
1import pandas as pd
2
3d = [ ["Mark", 12, 95],
4     ["Jay", 11, 88],
5     ["Jack", 14, 90]]
6
7df = pd.DataFrame(d, columns = ['Name','Age','Percent'])
8print(df)
9
Simona
03 Aug 2019
1d = [ ["Mark", 12, 95],
2     ["Jay", 11, 88],
3     ["Jack", 14, 90]]
4     
5print ("{:<8} {:<15} {:<10}".format('Name','Age','Percent'))
6
7for v in d:
8    name, age, perc = v
9    print ("{:<8} {:<15} {:<10}".format( name, age, perc))
10