Modifiedip
Modifiedip
CLASS-XII
INFORMATION PRACTICES
PROJECT- T20 score analysis
SUBMITTED BY:
Roll No:
Name:
Class:
Date:
Internal Examiner:
INTRODUCTION
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
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.
Here we can see we have 9 option and we selected 1 i.e, highest score.
https://www.tutorialaicsip.com/xii-practicals-ip/ip-project-
class-12-python-2
www.yahoo.com
www.google.com
NCERT INFORMATION PRACTICES TEXTBOOK