from tabulate import tabulate
print(tabulate([['Full Name','Mahendra Singh Pansingh Dhoni'],
['Born','July 07 1981'],['Birth Place','Ranchi, Bihar now jharkhand'],
['Nickname','Mahi,MSD,Captain cool,Thala'],['Movies','M.S.Dhoni:The Untold Story(2016 movie)'],
['Profession','Indian International Cricketer'],['Style','Right-Handed Batsman']],
headers=['Personal','Information']))
OUTPUT:-import matplotlib.pyplot as plt
fig,ax1 = plt.subplots()
years=[2018,2019,2007,2009,2018]
first=[1,2,1,2,1]
second=[10,15,17,11]
ax1.plot(years,first)
plt.show()
OUTPUT:-Score board with table form[[from tabulate import tabulatedata=[["Matches",90,350,98,264], ["Runs",4876,10773,1617,5243], ["Innings",144,297,85,229], ["Highest",224,183,56,84], ["Fours",544,826,116,383], ["Sixes",78,229,52,252], ["50s",33,73,2,24], ["100s",6,10,0,0]]headers=["Batting","Test","ODI","T20","IPL"]table=tabulate(data,headers,tablefmt="grid")print(table)OUTPUT:-+-----------+--------+-------+-------+-------+| Batting | Test | ODI | T20 | IPL |+===========+========+=======+=======+=======+| Matches | 90 | 350 | 98 | 264 |+-----------+--------+-------+-------+-------+| Runs | 4876 | 10773 | 1617 | 5243 |+-----------+--------+-------+-------+-------+| Innings | 144 | 297 | 85 | 229 |+-----------+--------+-------+-------+-------+| Highest | 224 | 183 | 56 | 84 |+-----------+--------+-------+-------+-------+| Fours | 544 | 826 | 116 | 383 |+-----------+--------+-------+-------+-------+| Sizes | 78 | 229 | 52 | 252 |+-----------+--------+-------+-------+-------+| 50s | 33 | 73 | 2 | 24 |+-----------+--------+-------+-------+-------+| 100s | 6 | 10 | 0 | 0 |+-----------+--------+-------+-Score board with represented by graphimport matplotlib.pyplot as pltfig,ax=plt.subplots(2,2)ax[0,0].plot([90,100,98],[200,280,350])ax[0,0].title.set_text("Matches")ax[0,1].plot([4000,4876,10000,10773],[1000,1617,5000,5243])ax[0,1].title.set_text("Runs")ax[1,0].plot([100,144,200,297],[80,85,200,229])ax[1,0].title.set_text("Innings")ax[1,1].plot([200,224,100,183],[50,56,80,84])ax[1,1].title.set_text("Highest")plt.show()OUTPUT:-Score Board with Bar Chart:-import numpy as npimport matplotlib.pyplot as pltdata=[[544,826,100,116,383], [78,229,50,52,252], [33,73,2,20,24]]x=np.arange(5)fig=plt.figure()ax=fig.add_axes([0,0,1,1])ax.bar(x+0.00,data[0],color='r',width=0.25)ax.bar(x+0.25,data[1],color='g',width=0.25)ax.bar(x+0.50,data[2],color='b',width=0.25)OUTPUT:-Score Board with Pie Chart:-# importing librariesfrom matplotlib import pyplot as pltimport numpy as np#Creating datasetdata1=['Runs','Highest','Fours','Sixes','50s','100s']data=[22509,547,1869,611,132,16]#Creating plotsfig=plt.figure(figsize=(10,7))plt.pie(data,labels=data1)#show plotplt.show()OUTPUT:-IPL Records with table form:-from tabulate import tabulatedata=[["Winner",2010,"CSK vs MI"], ["Winner",2011,"CSK vs RCB"], ["Winner",2018,"CSK vs SRH"], ["Winner",2021,"CSK vs KKR"], ["Winner",2023,"CSK vs GT"], ["Runner-up",2008,"CSK vs RR"], ["Runner-up",2012,"CSK vs KKR"], ["Runner-up",2013,"CSK vs MI"], ["Runner-up",2015,"CSK vs MI"], ["Runner-up",2019,"CSK vs MI"]]headers=["Win/Lose","Indian Premier League","Won Cup of"]table=tabulate(data,headers,tablefmt="grid")print(table)OUTPUT:-+------------+-------------------------+--------------+| Win/Lose | Indian Premier League | Won Cup of |+============+=========================+==============+| Winner | 2010 | CSK vs MI |+------------+-------------------------+--------------+| Winner | 2011 | CSK vs RCB |+------------+-------------------------+--------------+| Winner | 2018 | CSK vs SRH |+------------+-------------------------+--------------+| Winner | 2021 | CSK vs KKR |+------------+-------------------------+--------------+| Winner | 2023 | CSK vs GT |+------------+-------------------------+--------------+| Runner-up | 2008 | CSK vs RR |+------------+-------------------------+--------------+| Runner-up | 2012 | CSK vs KKR |+------------+-------------------------+--------------+| Runner-up | 2013 | CSK vs MI |+------------+-------------------------+--------------+| Runner-up | 2015 | CSK vs MI |+------------+-------------------------+--------------+| Runner-up | 2019 | CSK vs MI |+------------+---------------IPL Records with bar chart:-# importing librariesimport numpy as npimport matplotlib.pyplot as pltdata=[[2010,2011,2018,2021,2023], [2008,2012,2013,2015,2019]]x=np.arange(5)fig=plt.figure()ax=fig.add_axes([0,0,1,1])ax.bar(x+0.00,data[0],color='r',width=0.25)ax.bar(x+0.25,data[1],color='b',width=0.25)OUTPUT:-IPL Records with graph:-import matplotlib.pyplot as pltfig,ax1=plt.subplots()years=[2010,2011,2018,2021,2023,2008,2012,2013,2015,2019]first=[1,2,1,2,1,2,1,2,1,2]second=[2008,2012,2013,2015,2019]ax1.plot(years,first)plt.show()OUTPUT:-ICC,T20,Records with table form:-from tabulate import tabulatedata=[["Winner",2011,"India vs Srilanka","ICC World Cup"], ["Winner",2007,"India vs South Africa","ICC T20 World Cup"], ["Runner-up",2014,"India vs Bangladesh","ICC T20 World Cup"], ["Winner",2013,"India vs England Wales","ICC Champions Trophy"], ["Runner-up",2017,"India vs England Wales","ICC Champions Trophy"], ["Winner",2010,"India vs Srilanka","ACC Asia Cup"], ["Winner",2016,"India vs Bangladesh","ACC Asia Cup"], ["Winner",2018,"India vs UAE","ACC Asia Cup"], ["Runner-up",2008,"India vs Pakistan","ACC Asia Cup"]]headers=["Winner/Looser","Year","Matches","Won Cup of"]table=tabulate(data,headers,tablefmt="grid")print(table)OUTPUT:-+-----------------+--------+------------------------+----------------------+| Winner/Looser | Year | Matches | Won Cup of |+=================+========+========================+======================+| Winner | 2011 | India vs Srilanka | ICC World Cup |+-----------------+--------+------------------------+----------------------+| Winner | 2007 | India vs South Africa | ICC T20 World Cup |+-----------------+--------+------------------------+----------------------+| Runner-up | 2014 | India vs Bangladesh | ICC T20 World Cup |+-----------------+--------+------------------------+----------------------+| Winner | 2013 | India vs England Wales | ICC Champions Trophy |+-----------------+--------+------------------------+----------------------+| Runner-up | 2017 | India vs England Wales | ICC Champions Trophy |+-----------------+--------+------------------------+----------------------+| Winner | 2010 | India vs Srilanka | ACC Asia Cup |+-----------------+--------+------------------------+----------------------+| Winner | 2016 | India vs Bangladesh | ACC Asia Cup |+-----------------+--------+------------------------+----------------------+| Winner | 2018 | India vs UAE | ACC Asia Cup |+-----------------+--------+------------------------+----------------------+| Runner-up | 2008 | India vs Pakistan | ACC Asia Cup |+-----------------+--------+-ICC,T20,Records with graph:-import matplotlib.pyplot as pltfig,ax1=plt.subplots()years=[2011,2007,2014,2013,2017,2010,2016,2018,2008]first=[1,2,1,2,1,2,1,2,1]ax1.plot(years,first)plt.show()OUTPUT:-ICC,T20,Records with Bar chart:-#Import Librariesimport numpy as npimport matplotlib.pyplot as pltdata=[[2011,2007,2013,2010,2016], [2014,2017,2008,2024,2018]]x=np.arange(5)fig=plt.figure()ax=fig.add_axes([0,0,1,1])ax.bar(x+0.00,data[0],color='r',width=0.25)ax.bar(x+0.25,data[1],color='b',width=0.25)OUTPUT:-







0 Comments