0% found this document useful (0 votes)
73 views27 pages

Modifiedip

This document contains instructions for a project analyzing T20 cricket scores from a CSV file using Python. It includes sections on acknowledging assistance, certifying the project, introducing how to connect Python to MySQL, describing the project scope and tools used, providing sample source code to read the CSV file and perform analysis using Pandas and Matplotlib, and menus to view dataframe statistics, analyze records, and insert/delete records from the CSV file.

Uploaded by

sayantuf17
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views27 pages

Modifiedip

This document contains instructions for a project analyzing T20 cricket scores from a CSV file using Python. It includes sections on acknowledging assistance, certifying the project, introducing how to connect Python to MySQL, describing the project scope and tools used, providing sample source code to read the CSV file and perform analysis using Pandas and Matplotlib, and menus to view dataframe statistics, analyze records, and insert/delete records from the CSV file.

Uploaded by

sayantuf17
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 27

AISSCE PRACTICAL EXAM 2023-24

CLASS-XII
INFORMATION PRACTICES
PROJECT- T20 score analysis

KENDRIYA VIDYALAYA NEW BONGAIGAON

SUBMITTED BY:

Roll No:

Name:

Class:

Date:

 Signature of External Examiner:

 Signature of Internal Examiner:


CONTENTS
1. Acknowledgement
2. Certificate
3. Introduction
4. About Project
5. Source code
6. Sample run
7. Suggestions for Improvement
8. Bibliography
ACKNOWLEDGEMENT

As a student of class XII , I did this project as a part of my


studies entitled t20 run score analysis . I owe a deep sense
of gratitude to my ip teacher AMIT KUMAR PANDEY SIR
for his valuable advise , and his guidance helped me doing
this project from conception to completion . At the same
time I cannot forget to express my gratitude to our
principal sir for extending his support patronage and
constant encouragement . Finally I am thankful to my
friends for helping me economically and for being a helping
hand at every step of this project.
CERTIFICATE
This is to certify that Project entitled T20 score
analysis is original and genuinely developed by
SAYAN SAHA ,PRATYUSH NAG AND SAYAN DAS
for the fulfillment of requirement of SEE – 2023-
24 Practical Exam in the subject INFORMATION
PRATICES

Internal Examiner:
INTRODUCTION

Connecting Python application with MySQL

1. Every application required data to be stored for future reference


to manipulate data. Today every application stores data in
database for this purpose.
2. Python allows us to connect all types of database like Oracle, SQL
Server, MySQL.
3. Before we connect python program with any database like
MySQL we need to build a bridge to connect Python and MySQL.

To build this bridge so that data can travel both ways we need a
connector called “mysql.connector”.
We can install “mysql.connector” by using following methods:
At command prompt (Administrator login)
Type “pip install mysql.connector” and press enter
(internet connection in required)
This connector will work only for MySQL 5.7.3 or later
Or open “https://dev.mysql.com/downloads/connector/python/”
and download connector as per OS and Python version
4. Once the connector is installed you are ready to connect your
python program to MySQL.
The following steps to follow while connecting your python
program with MySQL
 Open python
 Import the package required (import mysql.connector)
 Open the connection to database
 Create a cursor instance
 Execute the query and store it in result-set
 Extract data from result-set
 Clean up the environment

5. Importing mysql.connector
import mysql.connector
Or
import mysql.connector as ms
Here “ms” is an alias, so every time we can use “ms” in place of
“mysql.connector”
6. Open a connection to MySQL Database
 To create connection, connect() function is used
 Its syntax is:
o ¤ connect(host=<server_name>,user=<user_name>,
o passwd=<password>[,database=<database>])
 Here server_name means database servername, generally it is
given as “localhost”
 User_name means user by which we connect with mysql
generally it is given as “root”
 Password is the password of user “root”
 Database is the name of database whose data(table) we want to
use
7. Creating Cursor
It is a useful control structure of database connectivity.
When we fire a query to database, it is executed and result-set
(set of records) is sent over he connection in one go.
We may want to access data one row at a time, but query
processing cannot happens as one row at a time, so cursor help
us in performing this task. Cursor stores all the data as a
temporary container of returned data and we can fetch data one
row at a time from Cursor.
8. Creating Cursor and Executing Query
TO CREATE CURSOR
Cursor_name = connectionObject.cursor()
For e.g.
mycursor = mycon.cursor()
TO EXECUTE QUERY
We use execute() function to send query to connection
Cursor_name.execute(query)
For e.g.
mycursor.execute(‘select * from emp’)
ABOUT PROJECT
Through this project we analyzed the data of T20 world cup
Batting of different countries using a csv file which is
downloaded from a source of internet and later on modified.
We have used line graph, bar graph, pie charts ,etc. which is a
part of the python library called matplotlib , and also a library
called pandas which helped us in creating this project .
Software used to create are-
 Windows 11 professional as operating system.
 Python pandas library , Mathplotlib library, etc.
 MS word 2019 as documentation .
 Snipping tools for screenshots
Hardware used in this project-
 Amd ryzen 7 5800h
 16 gb of ram
 64-bit operating system,x64 - based processor

To read csv file in python command used-


df=pd.read_csv("t20wc.csv")
SOURCE CODE(written form)
import pandas as pd
import matplotlib.pyplot as plt
while True:
print("MAIN MENU")
print("1.Dataframe Stats")
print("2.Record Analysis")
print("3.Insert Delete Record")
print("4.Data Visualization as per records")
print("5.Customized Data Visualization")
print("6.Exit")
ch=int(input("Enter Your Choice:"))
if(ch==1):
df=pd.read_csv("t20wc.csv")
print("Dataframe Properties:")
print("1.Diplay the transpose")
print("2.Display column names")
print("3.Display indexes")
print("4.Display the shape")
print("5.Display the dimension")
print("6.Display the data types of all columns")
print("7.Display the size")
print("8.Back")
ch1=int(input("Enter Your Choice:"))
if ch1==1:
print(df.T)
input("Press Enter to continue...")
elif ch1==2:
print(df.columns)
input("Press Enter to continue...")
elif ch1==3:
print(df.index)
input("Press Enter to continue...")
elif ch1==4:
print(df.shape)
input("Press Enter to continue...")
elif ch1==5:
print(df.ndim)
input("Press Enter to continue...")
elif ch1==6:
print(df.dtypes)
input("Press Enter to continue...")
elif ch1==7:
print(df.size)
input("Press Enter to continue...")
elif ch1==8:
pass
elif ch==2:
df=pd.read_csv("t20wc.csv")
print("RECORD ANALYSIS MENU")
print("1.Highest Score (Inning - Top 10)")
print("2.Lowest Score (Inning - Botton 10)")
print("3.Specific Number of Records From Top")
print("4.Specific Number of Records From
Bottom")
print("5.Details record for Sr.No.")
print("6.Details record for a Team")
print("7.Details record for a Batsman")
print("8.Most Runs (Top Ten)")
print("9.Least Runs (Bottom Ten)")
print("0.Back")
ch2=int(input("Enter Your Choice:"))
if ch2==1:
df1=df.loc[:,['city','name','runs','ballsFaced']]
df1=df1.sort_values(by='runs',ascending=False)
print(df1.head(10))
input("Press Enter to continue...")
elif ch2==2:
df1=df.loc[:,['city','name','runs','ballsFaced']]
df1=df1.sort_values(by='runs',ascending=False)
print(df1.tail(10))
input("Press Enter to continue...")
elif ch2==3:
no=int(input("How Many Number of Records
You Want To Be Printed From The Top:"))
df1=df.loc[:,['city','name','runs','ballsFaced']]
print(df1.head(no))
input("Press enter to continue...")
elif ch2==4:
n=int(input("How Many Number of Records You
Want To Be Printed From Bottom:"))
df1=df.loc[:,['city','name','runs','ballsFaced']]
print(df1.tail(n))
input("Press enter to continue...")
elif ch2==5:
sno=int(input("Enter The Sr.No. For Which You
Want The data To Be Displayed:"))
print(df.loc[sno])
input('Press enter to continue...')
elif ch2==6:
team=input("Enter The Sr.No. For Which You
Want The data To Be Displayed:")
df1=df.loc[df['team']==team]
print(df1.loc[:,['city','name','runs','ballsFaced']])
input('Press enter to continue...')
elif ch2==7:
print("Ensure the name should match with CSV
records:")
b=input("Enter The Sr.No. For Which You Want
The data To Be Displayed:")
df1=df.loc[df['name']==b]
print(df1.loc[:,['city','name','runs','ballsFaced']])
print('------------------------------------------------')
df1.at['Total','runs']=df1['runs'].sum()
print(df1)
input('Press enter to continue...')
elif ch2==8:
df1=df[['name','runs']].groupby('name').sum()
df1=df1.sort_values(by='runs',ascending=False)
print(df1.head(10))
input("Press enter to continue...")
elif ch2==9:
df1=df[['name','runs']].groupby('name').sum()
df1=df1.sort_values('runs')
print(df1.head(10))
input("Press enter to continue...")
elif ch2==0:
pass
else:
print("Invalid Choice")
elif(ch==3):
df=pd.read_csv("t20wc.csv")
print("Insert Delete record")
print("1.Insert a record")
print("2.Delete a records")
print("3.Exit The Records Menu")
ch3=int(input("Enter Your Choice:"))
if ch3==1:
col=df.columns
print(col)
j=0
rec={}
for i in col:
print("Enter",col[j],"value:")
nval=input()
rec[col[j]]=nval
j=j+1
df=df.append(rec,ignore_index=True)
print("Data is Successfully Updated")
df.to_csv('t20wc.csv',index=False)
input("Press enter to continue...")
elif ch3==2:
a=int(input("Enter S.No. whose data You Want to
be deleted:"))
df.drop([a-1],inplace=True)
df.to_csv('t20wc.csv',index=False)
print("Record deleted...")
input("Press enter to continue...")
elif ch3==3:
pass
elif(ch==4):
df=pd.read_csv("t20wc.csv")
print("Data Visualization Menu - According to no. of
rows")
print("1.Line Plot")
print("2.Vertical Bar Plot")
print("3.Horizontal Bar Plot")
print("4.Histogram")
print("5.Exit The Data Visualization Menu")
ch4=int(input("Enter Choice:"))
df1=pd.DataFrame()
if ch4==1:
n=int(input("How many records from the top of
table you want to plot:"))
df1=df.head(n)
df1.plot(linestyle="-.",linewidth=2,label="WORLD
CUP RECORD OF MS DHONI")
plt.show()
elif ch4==2:
n=int(input("How many records from the top of
table you want to plot:"))
df1=df.head(n)
df1.plot(kind="bar",color="pink",width=.8)
plt.show()
elif ch4==3:
n=int(input("How many records from the top of
table you want to plot:"))
df1=df.head(n)
df1.plot(kind="barh",color="cyan",width=.8)
plt.show()
elif ch4==4:
df.hist(color="yellow",edgecolor="pink")
plt.show()
elif ch4==5:
pass
elif(ch==5):
df=pd.read_csv("t20wc.csv")
print("Customized Data Visualization Menu")
print("1.By Player")
print("2.By Team")
print("3.Back")
ch5=int(input("Enter Choice:"))
df1=pd.DataFrame()
if ch5==1:
print("Ensure the name should match with CSV
records:")
player=input("Enter player name you want to
plot:")
print('''
1. Line Chart
2. Bar Chart
3. Horizontal Bar Chart
4. Histogram
5. Back
''')
ch5_1=int(input("Enter your choice:"))
if ch5_1==1:
df1=df.loc[df['name']==player]
df1=df1.loc[:,['against','runs']]

df1.plot(x='against',y='runs',kind='line',linestyle="-.",line
width=2,color='r')
plt.show()
elif ch5_1==2:
df1=df.loc[df['name']==player]
df1=df1.loc[:,['against','runs']]
df1.plot(x='against',y='runs',kind='bar',color='r')
plt.show()
elif ch5_1==3:
df1=df.loc[df['name']==player]
df1=df1.loc[:,['against','runs']]
df1.plot(x='against',y='runs',kind='barh',color='r')
plt.show()
elif ch5_1==4:
df1=df.loc[df['name']==player]
df1=df1.loc[:,['against','runs']]

df1.plot(x='against',y='runs',kind='hist',bins=25,cumulativ
e=True)
plt.show()
elif cf5_1==5:
pass
elif ch5==2:
print("Ensure the name should match with CSV
records:")
team=input("Enter team name you want to plot:")
print('''
1. Line Chart
2. Bar Chart
3. Horizontal Bar Chart
4. Histogram
5. Back
''')
ch5_2=int(input("Enter your choice:"))
if ch5_2==1:
df1=df.loc[df['team']==team]
df1=df1.loc[:,['name','runs']]

df1.plot(x='name',y='runs',kind='line',linestyle="-.",linewi
dth=2,color='r')
plt.show()
elif ch5_2==2:
df1=df.loc[df['team']==team]
df1=df1.loc[:,['name','runs']]
df1.plot(x='name',y='runs',kind='bar',color='r')
plt.show()
elif ch5_2==3:
df1=df.loc[df['team']==team]
df1=df1.loc[:,['name','runs']]
df1.plot(x='name',y='runs',kind='barh',color='r')
plt.show()
elif ch5_2==4:
df1=df.loc[df['team']==team]
df1=df1.loc[:,['name','runs']]

df1.plot(x='name',y='runs',kind='hist',bins=25,cumulative
=True)
plt.show()
elif ch5_2==5:
pass
elif ch==6:
print(' made by sayan saha')
print("Thanks for visiting , for more stay tuned with
sayan !!")
break
else:
print("*---------------------*INVALID
CHOICE*---------------------*")
SAMPLE RUN
To run the program we need to press f5.

If we choose option 1 . Then


To see the record analysis we choose option 2.

Here we can see we have 9 option and we selected 1 i.e, highest score.

If we choose option 4 of main menu we get the data visualization


Some more outputs are shown below:
For exiting from the program we select option 6.
SUGGESTIONS FOR IMPROVEMENT
BIBLIOGRAPHY

In order to work on this project of T20 world cup batting


analysis , the following websites are reffered to by me
during the various phases of development of the project

 https://www.tutorialaicsip.com/xii-practicals-ip/ip-project-
class-12-python-2
 www.yahoo.com
 www.google.com
 NCERT INFORMATION PRACTICES TEXTBOOK

Other than the above mentioned sites , the suggestion and


supervision of my teacher and my class experience have
also helped me develop this project .

You might also like