CLASS 12 IP PRACTICAL FILE (2) - Pages-Deleted (1) - Output
CLASS 12 IP PRACTICAL FILE (2) - Pages-Deleted (1) - Output
Problem statement: Collect and store total medals won by 10 countries in Olympic games
and represent it in form of bar chart with title to compare an analyze data.
Solution:
Source Code:
import matplotlib.pyplot as plt
medals = [213,224,300,59,100,140,256,98,60,24]
country = ['Ger','Itly','USA','Jamca','Japan',
'India','China','Aus','Arg','Ethopia']
plt.bar(country, medals)
plt.title('Olympics Medal Tally')
plt.show()
Screenshot:
Output
PRATICAL 23
Problem statement: Given the school result data, analyses the performance of the student
on different parameters, e.g. subject wise or class wise. Create a dataframe for the above,
plot appropriate chart with title and legend.
Eng Math Phy Chm IT
9 78 89 69 92 96
10 89 91 84 90 98
11 90 80 76 82 90
12 94 98 90 96 100
Solution:
Source Code:
import pandas as pd
import matplotlib.pyplot as plt
d = {'eng':[78,89,90,94],'math':[89,91,80,98],
'phy':[69,84,76,90],'chm':[92,90,82,96],
'IT':[96,98,90,100]}
df = pd.DataFrame(d,[9,10,11,12])
print(df)
df.plot(kind = 'bar',title = 'Class Wise Marks Analysis',
xlabel = 'Class', ylabel = 'Marks')
df1 = df.T
df1.plot(kind = 'bar',title = 'Subject Wise Marks Analysis',
xlabel = 'Class', ylabel = 'Marks')
plt.legend(loc = 'lower center')
plt.show()
Screenshot:
Output
PRATICAL 24
Problem statement: The following seat bookings are the daily records of a month
December from PVR cinemas:
124,124,135,156,128,189,200,150,158, 150,200,124,143,142,130,130, 170,
189,200,130, 142,167,180,143,143, 135,156,150,200,189,189,142
Construct a histogram from above data with 10 bin..
Solution:
Source Code:
import pandas as pd
import matplotlib.pyplot as plt
L = [124,124,135,156,128,189,200,150,158,
150,200,124,143,142,130,130, 170,
189,200,130, 142,167,180,143,143,
135,156,150,200,189,189,142]
plt.hist(L)
plt.title("Booking Records @ PVR")
plt.show()
Screenshot:
Output
PRATICAL 25
Problem statement: Take data of your interest from an open source (e.g. data.gove.in),
aggregate and summarize it. Then plot it using different plotting functions of the Matplotlib
library.
Solution:
Source Code:
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv('c:\sample\Crime_data.csv')
print(df)
plt.bar(df.Crime,df.Boys,width = 0.25)
plt.bar(0.25,df.Girls,width = 0.25)
plt.bar(0.5,df.Transgender,width = 0.25)
df.plot(kind = 'bar', x = 'Crime')
df.plot(kind = 'bar', x= 'Crime', y= ['Boys','Girls', 'Transgender'])
plt.show()
Screenshot:
Output
MySQL
Practicals
PRATICAL 26
Problem statement: Create a student table with the student id, name, and marks as
attributes where the student id is the primary key.
Solution:
Source Code:
create table student
( -> studid int primary key,
-> name varchar(30),
-> marks int
-> );
Screenshot:
PRATICAL 27
Problem statement: In the table ‘student’ created in practical 26, insert the details of new
students.
Solution:
Source Code:
insert into student values(1, 'sanjay', 67);
mysql> insert into student values(2, 'surendra', 88);
mysql> insert into student values(3, 'Jamil', 74);
mysql> insert into student values(4, 'Rahul', 92);
mysql> insert into student values(5, 'Prakash', 78);
Screenshot:
PRATICAL 28
Problem statement: Write SQL command to get the details of the students with marks
more than 80.
Solution:
Source Code:
select * from student where marks >=80;
Screenshot:
PRATICAL 29
Problem statement: Write SQL command to Find the min, max, sum, and average of the
marks in a student marks table..
Solution:
Source Code:
select min(marks) as Min_marks, max(marks) as Max_Marks, sum(marks) as
Total_Marks, avg(marks) as Average_Marks from student;
Screenshot:
PRATICAL 30
Problem statement: Delete the details of a student table created in Practical 26.
Solution:
Source Code:
Delete from student;
Screenshot:
PRATICAL 31
Problem statement: Find the total number of customers from each country in the table
(customer ID, customer Name, country) using group by.
Solution:
Source Code:
select country, count(cname) as 'Total_Customers' from customer
group by country;
Screenshot:
PRATICAL 32
Problem statement: Write a SQL query to order the (student ID, marks) table in descending
order of the marks.
Solution:
Source Code:
select * from student Order By name DESC;
Screenshot:
PRATICAL 33
Problem statement: for the given table ‘Hospital’ write SQL command to display name all
patient admitted in month of May.
PID PNAME ADMITDATE DEPT FEES
AP/PT/001 Rahil Khan 21/04/2019 ENT 250
AP/PT/002 Jitendal Pal 12/05/2019 Cardio 400
AP/PT/003 Suman Lakra 19/05/2019 Cardio 400
AP/PT/004 Chandumal Jain 24/06/2019 Neuro 600
.
Solution:
Source Code:
select * from hospital where monthname(admitdate) = 'May';
Screenshot:
PRATICAL 34
Problem statement: for the given table ‘Hospital’ write SQL command to Display patient
name in upper case with year of admission.
PID PNAME ADMITDATE DEPT FEES
AP/PT/001 Rahil Khan 21/04/2019 ENT 250
AP/PT/002 Jitendal Pal 12/05/2019 Cardio 400
AP/PT/003 Suman Lakra 19/05/2019 Cardio 400
AP/PT/004 Chandumal Jain 24/06/2019 Neuro 600
.
Solution:
Source Code:
Select UPPER(pname) as ‘patient name’, YEAR(admitdate) as ‘admit year’
From hospital;
Screenshot:
PRATICAL 35
Problem statement: for the given table ‘Hospital’ Create sql query to display first four
letters of the patient name along with length of their name who admitted before may.
PID PNAME ADMITDATE DEPT FEES
AP/PT/001 Rahil Khan 21/04/2019 ENT 250
AP/PT/002 Jitendal Pal 12/05/2019 Cardio 400
AP/PT/003 Suman Lakra 19/05/2019 Cardio 400
AP/PT/004 Chandumal Jain 24/06/2019 Neuro 600
.
Solution:
Source Code:
Select LEFT(pname,4) as ‘pname’, length(pname) as ‘length’
From hospital
Where month(admitdate) < 5;
Screenshot: