TLISW_Class XII IP Practical file
The Lexicon International School, Wagholi
Practical File Class XII
Class: XII
_____________________________________________________________________________________
#1 Write a program in Python to create a series object that has 10 elements in
the range 10 to 100.
Solution:
Output:
#2 Write a Pandas program to multiple and divide two Pandas Series.
Sample Series: [2, 4, 8, 10], [1, 3, 7, 9]
Solution:
TLISW_Class XII IP Practical file
Output:
#3 Write a program in Python to create a pandas series, that stores the area of
state names and their areas in km2. Write a code to find the areas of the state
that are more than 5000km2
Solution:
Output:
TLISW_Class XII IP Practical file
#4 Write a Pandas program to get the first and last 3 rows of a given DataFrame.
Solution:
Output:
TLISW_Class XII IP Practical file
#5. Consider the following dataframe df
Write a program to add a column namely order having values 6000, 7000 and
8000 for the zones A,B,C respectively. The program should also add new row
for the Zone D, values as 800,900,500.
Zones Target Sales
A 2000 3000
B 5000 6000
C 7000 8000
Solution:
TLISW_Class XII IP Practical file
#6. Create a data frame based on ecommerce data and generate descriptive
statistics (mean, median, mode, quartile, and variance).
Solution:
Output:
TLISW_Class XII IP Practical file
#7. Create a data frame for examination result and display row labels, column
labels data types of each column and the dimensions
Solution:
OutPut:
TLISW_Class XII IP Practical file
#8. Write a Python code to create the following data frame from a Dictionary
I. Write code to display the name and Salary, of employee who is earning
more than salary more than 5000
II. Write code to add new column ‘Commission’ with values as 5% of Salary.
III. Write code to delete the data of ‘Bipin’ from the data frame
Solution:
Output:
TLISW_Class XII IP Practical file
#9. Consider the following DataFrame df as shown below
I. Write code to display name of the player who have scored maximum
runs.
II. Write code to add new column ‘BMI’ calculated as(BMI=weight/height2)
III. Find the name of the player with minimum age.
Solution:
TLISW_Class XII IP Practical file
OUTPUT:
TLISW_Class XII IP Practical file
#10. Write a Pandas program to change the order of index of a given series.
Original Data Series:
A 1
B 2
C 3
dtype: int64
Data Series after changing the order of index:
B 2
A 1
C 3
dtype:
Solution: int64
Output:
TLISW_Class XII IP Practical file
#11. Write a Pandas program to convert a dictionary to a Pandas series.
Sample dictionary: d1 = {'a': 100, 'b': 200, 'c':300}
Solution:
Output:
#12. Create a dataframe furniture shown in the following table
i. Display the details of the chair and sofa.
ii. Display furniture details where price is under 10,000.
iii. Display count of number of rows and numbers of column in the Data
Frame
TLISW_Class XII IP Practical file
Output:
#13. Write a python code to create a dataframe with appropriate headings from
the list given below :
['S101', 'Amy', 70], ['S102', 'Bandhi', 69], ['S104', 'Cathy', 75], ['S105', 'Gundaho',
82]
TLISW_Class XII IP Practical file
Solution:
Output
#14. Importing and exporting data between pandas and CSV file
TLISW_Class XII IP Practical file
#15. Importing and exporting data between pandas and MySQL database.
Importing Data from MYSQL
TLISW_Class XII IP Practical file
Output
Exporting Data to MYSQL using Pandas
TLISW_Class XII IP Practical file
#16. Plot double line graph for the given data set. Customize the plots with color, style
(dashed, dotted) and proper legend
Year English Pass Percentage Math Pass Percentage
2014 50 50
2015 60 70
2016 70 60
2017 80 80
Output
TLISW_Class XII IP Practical file
#17. Plot horizontal bar chart for the following data set
The bar in the graph should be in green color. There should be proper labels for X axis and
y axis. The title of the chart should be ‘World Population’
Country Population
India 130
China 140
USA 33
Indonesia 22
Banladesh 16
Solution:
Output:
TLISW_Class XII IP Practical file
#18. Question: Draw line chart showing comparative scores of the cricket team
of India and England as per the details given below in two different plots using
subplot().Title: India vs England X label: overs Y Label: Runs.
Overs 1 2 3 4 5
Runs(India) 10 3 14 15 4
Runs(England) 4 9 3 8 10
Solution:
TLISW_Class XII IP Practical file
Solution:
#19. The following tables give the information about patient body
Temperature recorded in the hospital every hour.
Draw line graph for the above data using Matplotlib with appropriate label title and
legend placed on Lower right .
Time [Link] [Link] [Link] [Link] [Link]
Temperature 28C 32C 36C 39C 40C
Solution
Solution:
TLISW_Class XII IP Practical file
#20. Plot a bar chart depicting the employee name on X axis and their
corresponding salary and on y axis with appropriate graph title x-axis, y-axis,
color as black and legend placed on top left corner.
Solution:
TLISW_Class XII IP Practical file
#21. Plot a double bar chart depicting the number of voters. The bar chart should display the
number of voters each year. Please provide with appropriate graph title x-axis, y-axis, color and
legend placed on top left corner.
Year Men Women
1990 70000 10000
1991 80000 20000
1992 90000 30000
1993 80000 40000
TLISW_Class XII IP Practical file
Solution:
TLISW_Class XII IP Practical file
#22. Plot scatter chart depicting grades of boys and girls in a class.
Grades Girls Boys
A1 89 30
A2 90 29
B1 70 49
B2 89 49
C1 100 100
C2 80 48
D 90 38
Solution:
Output:
TLISW_Class XII IP Practical file
#23. Plot pie chart depicting percentage of admissions with 2 decimal values in
a school for class XI.
Explode the stream with maximum admission.
Science Commerce Humanities
100 89 30
Solution:
Output:
TLISW_Class XII IP Practical file
#24. Write program to create box plot from the following set of data for
weekly sales of XYZ enterprises.
Week1= [34,18,100,27,70,93,59,87,78,82,91]
Week2= [34,18,100,27,80,93,59,87,78,82,91]
Week3= [34,18,90,27,54,93,59,87,78,82,91]
Science
Solution: Commerce Humanities
Output
#25. Write program to plot Histogram of marks with following bin.
TLISW_Class XII IP Practical file
Solution:
Solution:
#26. Create a table student with under mentioned structure usingSQL
TLISW_Class XII IP Practical file
A. Write queries for the following
TLISW_Class XII IP Practical file
To display all the student’s name whose birthday is in the monthof
August or September.
Select stdName,DOB from Student
where monthname(DOB) = ‘August’ or monthname(DOB) = ‘September’
TLISW_Class XII IP Practical file
#27. Consider the following TEACHERS table
[Link] following Sales table
InvoiceNO CardId Custd SaleDate PaymentMode Empid SalePrice
I00001 D001 C0001 2019-01-24 Credit card E004 613247
I00002 S001 C0002 2018-12-12 Online E001 590321
I00003 S002 C0004 2019-01-25 Cheque E010 604000
I00004 D002 C0001 2018-12-15 Bank Finance E007 659982
I00005 E001 C0003 2018-12-20 Credit card E002 369310
I00006 S002 C0002 2019-01-30 Bank Finance E007 620214
TLISW_Class XII IP Practical file
Display the Customer id and number of cars purchased if the customer purchased
more than 1 car from SALE table
Mysql> Select CUSTID,count(*) from SALE group by CUSTID having count(*)>1
TLISW_Class XII IP Practical file
Display sum of sales price for customer id =C0001
Select sum(SalePrice) from sale where CustId = “C0001”;
Display sum of sales price for every customer in the table
Select sum(salesprice),custId from sale group by custId;
Display average sales price in the sales table
Select avg(salesprice) from sale;
#29. Create the following table LOANS and answer the following SQLcommands.
Create table loan and insert above rows in the table
TLISW_Class XII IP Practical file
Display the AccNo and Loan_Amount of all the loans started before 01- 04-2009.
select loan_amount,accno,start_date from loans where start_date <'2009-04-01';
Display the details of all the loans started before 31-12-2008 for which the number of
instalments are more than 36.
Ans. select * from loans where start_date<'2008-12-31' and installment>36;
Display the details of all the loans whose rate of interest is in the range 11% to 12%.
Ans. select * from loan where interest between 11 and 12;
Display the AccNo, Cust_Name, and Loan_Amount for all the loans for which the Cust_Name ends
with 'Sharma’.
select acc_no, cust_name, loan_amount from loans where cust_name like '%Sharma';
Display the AccNo, Cust_Name, and Loan_Amount for all the loans for which the Cust_Name
contains 'a' as the second last character
select AccNo, Cust_Name, Loan_Amount from loans where Cust_Name like '%a_';
Display the AccNo, Cust_Name, and Loan_Amount for all the loans for which the Cust_Name does
not contain ‘P’
select AccNo, CustName, LoanAmt from loans where CustName not like '%P%';
Display the AccNo, Cust_Name, and Loan_Amount for all the loans for which the Cust_Name
contains 'a’.
select accno,cust_name,loan_amount from loans where cust_name like '%A%';
Increase the interest rate by 0.5% for all the loans for which the loan amount is more than
400000.
update loans set IntRate = IntRate + 0.5 where LoanAmt > 400000;
Delete the records of all the loans whose start date is before 2007.
delete from loans where year(StartDate) < 2007;
Add new column Category of type varchar in the Loan table.
alter table loans add column Category varchar(20);
• Display the sum of all Loan Amount for whose Interest rate is greater than 10.
select sum(loan_amount) from loans where int_rate>10;
TLISW_Class XII IP Practical file
• Display the name,count of all loan holders whose name is ending with ‘Sharma’.
select count(*) from loans where CustName like '%Sharma';
• Display the Interest wise details of Loan Account Holders.
select * from loans order by interest;
• Display the Interest wise details wise details of Loan Account Holders with at least 10
installments remaining.
#30. Write the output produced by the following SQL commands:
1. SELECT POW(4,3), POW(3,4);
Ans: 64, 81
2. SELECT ROUND(543.5694,2), ROUND(543.5694), ROUND(543.5694,-1);
Ans: 543.57, 544, 540
3. SELECT TRUNCATE(543.5694,2), TRUNCATE(543.5694,-1);
Ans: 543.56, 540
4. SELECT LENGTH("Prof. M. L. Sharma");
Ans: 18
5. SELECT CONCAT("SHEIKH", " HAROON") "FULL NAME";
Ans: SHEIKH HAROON
6. SELECT YEAR(CURDATE()), MONTH(CURDATE()), DAY(CURDATE());
Ans: 2019, 08, 26
7. SELECT DAYOFYEAR(CURDATE()), DAYOFMONTH(CURDATE()), DAYNAME(CURDATE());
Ans: 2019, 2, Monday
8. SELECT LEFT("Unicode",3), RIGHT("Unicode",4);
Ans: Uni, code
9. SELECT INSTR("UNICODE","CO"), INSTR("UNICODE","CD");
10. select interest from loans where installment <=10;
11.
Ans: 4, 0
TLISW_Class XII IP Practical file
Index
Sr. no Experiment Date of Date of
Experiment submission
1 Write a program in 25/06/2023 28/06/2023
Python to create a
series object that has
10 elements in the
range 10 to 100.
2 Write a Pandas program to 29/06/2023 30/06/2023
multiple and divide two
Pandas Series
3 Write a program in Python 5/07/2023 7/06/2023
to create a pandas frame,
that stores the area of state
names and their areas in
km2
4 Write a Pandas program to 15/07/2023 16/07/2023
get the first and last 3 rows
of a given DataFrame
5 Write a program to add a 16/07/2023 19/07/2023
column in data frame
6 Descriptive statistical
analyses
7 Create a data frame for 20/07/2023 22/07/2023
examination result and
display row labels, column
labels data
8 Write a Python code to 26/07/2023 28/07/2023
create the data frame from
a Dictionary
9 Write a Pandas program to 28/07/2023 30/07/2023
show maximum marks
scored
10 Write a Pandas program to 05/08/2023 08/08/2023
change the order of index
of a given series
11 Write a Pandas program to 10/08/2023 12/08/2023
convert a dictionary to a
Pandas series.
12 Create a data frame and 2/09/2023 5/09/2023
display of data with
conditions
13 Program to create a data 10/09/2023 12/09/2023
frame with appropriate
headings from the list
TLISW_Class XII IP Practical file
14 Importing and exporting 15/09/2023 18/09/2023
data between pandas and
CSV file
15 Importing and exporting 22/09/2023 24/09/2023
data between pandas and
MySQL database.
16 Plot double line graph for 01/10/2023 03/10/2023
given data
17 Plot horizontal bar chart 05/10/2023 06/10/2023
for the following data set
18 Draw line chart showing 08/10/2023 09/10/2023
comparative scores of the
cricket team
19 Draw line graph with 15/10/2023 16/10/2023
appropriate label title
and legend placed on
Lower right.
20 Plot a bar chart 18/10/2023 20/10/2023
21 Plot a double bar chart 26/10/2023 28/10/2023
depicting the number of
Voters
22 Plot scatter chart 28/10/2023 30/10/2023
23 Plot pie chart depicting 31/10/2023 1/11/2023
percentage of admissions
24 Write program to plot 1/11/2023 2/11/2023
box plot
25 Write program to plot 3/11/2023 4/11/2023
histogram
26 -30 SQL Queries 6/11/2023 10/11/2023
TLISW_Class XII IP practical file
Page 36 of 36