2
TABLE OF CONTENTS
S.No Name of the Exercises Page.No
Programs using Pandas
SERIES
1. Creating a Python program to create a series using a dictionary. 3
2. Creating a Python program to create a series using scalar value. 4
3. Creating a Python program to create a series using NumPy array. 5
4. Creating a python program for modifying or updating existing values of series
object.
6
5. Creating a Python program for performing mathematical operations on two
Series objects.
7
6. Creating a Python program for calculating per capita income of four zones
using Series.
8
7. Creating a Python program to display attributes of a Series. 9
8. Creating a Python program using head() and tail() in Series. 10
DATAFRAME
9. Creating a Python program for creating a DataFrame using a nested list. 11
10. Creating a python program for accessing values of rows and columns of a
dataframe.
12
11. Creating a Python program for accessing values of rows and columns of a
DataFrame.
14
12. Creating a python program to perform operations on a DataFrame (rename,
count, update, replace)
16
13. Creating a Python program to filter the data of a DataFrame. 18
14. Creating a Python program to display the attributes of the DataFrame. 19
15. Creating a Python program to display the data of a DataFrame row-wise and
column-wise using iterrows() and iteritems()
20
16. Creating a Python program to perform writing and reading operations in a
CSV file.
22
Programs using Matplotlib – Data Visualization
17. Creating a python program for plotting a line chart. 23
18. Creating a python program for plotting a bar chart from a CSV file. 24
19. Creating a python program for plotting a multiple bar chart from a CSV file. 25
20. Creating a python program for plotting Histogram. 26
SQL Queries
21. SQL COMMANDS EXERCISE – 1 (Basic Queries – I) 27
22. SQL COMMANDS EXERCISE – 2 (Basic Queries – II) 29
23. SQL COMMANDS EXERCISE – 3 (Aggregate functions, Order by Group by,
Having Clause)
31
24. SQL COMMANDS EXERCISE – 4 (Math Functions) 33
25. SQL COMMANDS EXERCISE – 5 (Text Functions) 35
26. SQL COMMANDS EXERCISE – 6 (Date Functions) 37
3
EX.NO: 1
DATE:
CREATING A PYTHON PROGRAM TO CREATE A
SERIES USING A DICTIONARY.
AIM:
To write a Python program to create a Series to store 5 students Percentage Using
dictionary and print all the elements that are above 75 percentage.
SOURCE CODE:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
SAMPLE OUTPUT:
************************************************************************************************
4
EX.NO: 2
DATE:
CREATING A PYTHON PROGRAM TO CREATE A
SERIES USING SCALAR VALUE
AIM:
To write a Python program to create a Series object that stores the Initial budget
allocated (50000/- each) for the four quarters of the year: Qtr1, Qtr2, Qtr3 and Qtr4.
SOURCE CODE:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
SAMPLE OUPUT:
5
EX.NO: 3
DATE:
CREATING A PYTHON PROGRAM TO CREATE A
SERIES USING NUMPY ARRAY
AIM:
To write a Python program to create a Series object that stores the Employee names
as index and their Salary as values
SOURCE CODE:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
SAMPLE OUTPUT:
*************************************************************************************************
6
EX.NO: 4
DATE:
CREATING A PYTHON PROGRAM FOR MODIFYING OR UPDATING EXISTING VALUES
OF SERIES OBJECT.
AIM:
To Write a Python program to create a Series object with Employee names as the index
and their salaries as values. Accept the name of the employee whose salary needs to be
changed, along with the new salary, and update it in the Series.
Source Code:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
Sample Output:
****************************************************************************************
7
EX.NO: 5
DATE:
CREATING A PYTHON PROGRAM FOR PERFORMING MATHEMATICAL
OPERATIONS ON TWO SERIES OBJECTS
AIM:
To create a program in python to perform following mathematical Operations on Two
Series objects: (i) Addition (ii) Subtraction (iii) Multiplication (iv) Division.
SOURCE CODE:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
SAMPLE OUTPUT:
**************************************************************************************************
8
EX.NO: 6
DATE:
CREATING A PYTHON PROGRAM FOR CALCULATING PER CAPITA INCOME OF
FOUR ZONES USING SERIES
AIM:
To write a Python program to create two series i.e. population and average
income of Four Zones, and then calculate per capita income storing in third
pandas series print it.
Source Code:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
Sample Output:
***************************************************************************************
9
EX.NO: 7
DATE:
CREATING A PYTHON PROGRAM TO DISPLAY ATTRIBUTES OF A SERIES
AIM:
To write a Python program to create a Series using list and display the following
attributes of the Series: (i) index (ii) dtype (iii) size (iv) shape (v) hasnans
SOURCE CODE:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
SAMPLE OUTPUT:
*************************************************************************************************
10
EX.NO: 8
DATE:
CREATING A PYTHON PROGRAM USING head() AND tail() IN SERIES
AIM:
To write a Python program to create a Series using list of Marks of 10 students and
display first 5 Students’ marks and Last 2 Students’ marks from Series object.
SOURCE CODE:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
SAMPLE OUTPUT:
**************************************************************************************************
11
EX.NO: 9
DATE:
CREATING A PYTHON PROGRAM FOR CREATING A DATAFRAME USING A
NESTED LIST
AIM:
To write a Python program to create a panda’s Data Frame for the following table Using
Nested list:
SOURCE CODE:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
SAMPLE OUTPUT:
**************************************************************************************************
12
EX.NO: 10
DATE:
CREATING A PYTHON PROGRAM FOR ACCESSING VALUES OF ROWS AND
COLUMNS OF A DATAFRAME
AIM:
To write a Python program to create a panda’s DataFrame called DF for the following
table Using Dictionary of List and perform the following operations:
(i) To Display only column 'Toys' from DataFrame DF.
(ii) To Display the row details of 'AP' and 'OD' from DataFrame DF.
(iii) To Display the column 'Books' and 'Uniform' for 'M.P' and 'U.P' from DataFrame DF.
(iv) To Display consecutive 3 rows and 3 columns from DataFrame DF.
SOURCE CODE:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
13
SAMPLE OUTPUT:
*************************************************************************************************
14
EX.NO: 11
DATE:
CREATING A PYTHON PROGRAM FOR ACCESSING VALUES OF ROWS AND COLUMNS
OF A DATAFRAME
AIM:
To write a Python program to create a panda’s DataFrame called DF for the following
table Using Dictionary of List and perform the following operations:
(i) Insert a new column “Bags” with values as [5891, 8628, 9785, 4475].
(ii) Delete the row details of M.P from DataFrame DF.
SOURCE CODE:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
15
SAMPLE OUTPUT:
**************************************************************************************************
16
EX.NO: 12
DATE:
CREATING A PYTHON PROGRAM TO PERFORM OPERATIONS ON A DATAFRAME
(RENAME, COUNT, UPDATE, REPLACE)
AIM:
To write a Python program to create a pandas DataFrame to analyze number of
Government and Private medical college and their Total seats,Fees statewise details
using the dataset available at www.data.gov.in. Also, perform the following operations.
(i) To Change the name of the state AP to Andhra.
(ii) To Count and Display Non-NaN values of each column.
(iii) To Count and Display Non-NaN values of each row.
(iv) To Increase the fees of all colleges by 5%
(v) To Replace all NaN values with 0.
Source Code:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
17
Sample Output:
*************************************************************************************
18
EX.NO: 13
DATE:
CREATING A PYTHON PROGRAM TO FILTER THE DATA OF A DATAFRAME
AIM:
To write a Python program to create a panda’s DataFrame called DF for the following table
using Dictionary of List and display the details of students whose Percentage is more than
85.
SOURCE CODE:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
SAMPLE OUTPUT:
*******************************************************************************************
19
EX.NO: 14
DATE:
CREATING A PYTHON PROGRAM TO DISPLAY THE ATTRIBUTES OF A
DATAFRAME
AIM:
To write a Python program to create a DataFrame using Dictionary of list and display
the following attributes of the DataFrame: (i) index (ii) columns (iii) axes (iv) dtypes
(v) shape (vi) dimension (vii) T
SOURCE CODE:
RESULT:
Thus, the above Python program is executed successfully and the output is verified.
SAMPLE OUTPUT:
*******************************************************************************************
20
EX.NO: 15
DATE:
CREATING A PYTHON PROGRAM TO DISPLAY THE DATA OF A DATAFRAME
ROW-WISE AND COLUMN-WISE USING ITERROWS() AND ITERITEMS()
AIM:
To write a Python program to create a panda’s DataFrame called Students for the
following table and demonstrate iterrows and iteritems.
SOURCE CODE:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
21
SAMPLE OUTPUT:
# Output for Iterrows() # Output for Iteritems()
**********************************************************************************************
22
EX.NO: 16
DATE:
CREATING A PYTHON PROGRAM TO PERFORM WRITING AND READING OPERATIONS
IN A CSV FILE
AIM:
To Write a Python program to store the details of Employess’ such as Empno, Name,
Salary into a Employee.csv file. Also, write a code to read employee details from csv
file.
SOURCE CODE:
RESULT:
Thus, the above Python program has been executed successfully, and the output has
been verified.
SAMPLE OUTPUT:
**********************************************************************************************
23
EX.NO: 17
DATE:
CREATING A PYTHON PROGRAM FOR PLOTTING A LINE CHART
AIM:
To write a Python program to plot a Line chart to depict the changing weekly Onion
and Brinjal prices for four weeks. Also, give appropriate axes labels, title and keep marker
style as Diamond and marker edge color as ‘red’ for Onion.
SOURCE CODE:
RESULT:
Thus, the above Python program has been executed and verified successfully, and its
respective chart has been generated successfully.
SAMPLE OUTPUT:
*********************************************************************************************
24
EX.NO: 18
DATE:
CREATING A PYTHON PROGRAM FOR PLOTTING A BAR CHART
FROM A CSV FILE
AIM:
To write a Python program to create a DataFrame for subject-wise average, save it to
a CSV file, and then draw a bar chart using Matplotlib with a width of each bar as 0.25,
specifying different colors for each bar. Additionally, provide a proper title and axes labels for
the bar chart.
Source Code:
RESULT:
Thus, the above Python program has been executed and verified successfully, and its
respective chart has been generated successfully.
Sample Output:
***********************************************************************************************
25
EX.NO: 19
DATE:
CREATING A PYTHON PROGRAM FOR PLOTTING A MULTIPLE
BAR CHART FROM A CSV FILE
AIM:
To write a Python program to plot a multiple bar chart From CSV file using Matplotlib
for subject wise Scores of Class A, Class B, and Class C. Different colors represent each
class, and subjects include English,Accountancy,Economics,BST and IP. Proper labels,
a title and a legend are displayed on the chart.
Source Code:
RESULT:
Thus, the above Python program has been executed and verified successfully, and its
respective chart has been generated successfully.
Sample Output:
*****************************************************************************************************
26
EX.NO: 20
DATE:
CREATING A PYTHON PROGRAM FOR PLOTTING
PLOTTING HISTOGRAM
AIM:
To write a Python program to plot a Histogram for the following class interval or
range. Also, give appropriate axes name, title and edege color as ‘red’.
SOURCE CODE:
RESULT:
Thus, the above Python program has been executed and verified successfully, and the
respective chart has been generated successfully.
SAMPLE OUTPUT:
******************************************************************************************
27
Ex.No: 21
DATE:
SQL COMMANDS EXERCISE – 1
(Basic Queries – I)
AIM:
To write Queries for the following Questions based on the given table:
EmpID Name Gender Age Dept DOJ Salary City
1 Praveen M 25 Sales 1989-06-08 20000 Chennai
2 Arun M 29 Marketing 1989-09-26 22000 Chennai
3 Usha F 27 Finance 1994-08-09 25000 Bangalore
4 Bala M 31 Sales 1990-03-23 27000 NULL
5 Rani F 28 Marketing 1990-04-23 27000 Mumbai
6 Nisha F 26 NULL 1991-02-24 18000 Bangalore
7 Manoj M 32 Finance 1982-05-06 30000 Goa
(a) Write a Query to Create a new database in the name of "EMPS".
CREATE DATABASE EMPS;
(b) Write a Query to Open the database EMPS.
USE EMPS;
(c) Write a Query to create the above table called: Info
CREATE TABLE INFO (EmpID int primary key, Name varchar(15),
Gender varchar(3),Age int,Dept varchar(15),DOJ date, Salary int, City varchar(10));
(d) Write a Query to list all the existing database names.
SHOW DATABASES;
28
(e) Write a Query to List all the tables that exists in the current database.
SHOW TABLES;
Output:
(f) Write a Query to insert all the rows of above table into Info table.
INSERT INTO INFO VALUES (1,'Praveen','M', 25,'Sales','1989-06-08','20000','Chennai');
INSERT INTO INFO VALUES(2,'Arun','M',29,'Marketing','1989-09-26',22000,'Chennai');
INSERT INTO INFO VALUES(3,'Usha','F',27,'Finance','1994-08-09',25000,'Bangalore');
INSERT INTO INFO VALUES(4,'Bala','M',31,'Sales','1990-03-23',27000,NULL);
INSERT INTO INFO VALUES(5,'Rani','F',28,'Marketing','1990-04-23',27000,'Mumbai');
INSERT INTO INFO VALUES (6,'Nisha','F', 26, NULL,'1991-02-24', 18000,'Bangalore');
INSERT INTO INFO VALUES (7,'Manoj','M', 32,'Finance','1982-05-06', 30000,'Goa');
(g) Write a Query to display all the details of the Employees from the above table 'INFO'.
SELECT * FROM INFO;
Output:
****************************************************************************************************
29
Ex.No: 22
DATE:
SQL COMMANDS EXERCISE – 2
(Basic Queries – II)
AIM:
To write Queries for the following Questions based on the given table:
EmpID Name Gender Age Dept DOJ Salary City
1 Praveen M 25 Sales 1989-06-08 20000 Chennai
2 Arun M 29 Marketing 1989-09-26 22000 Chennai
3 Usha F 27 Finance 1994-08-09 25000 Bangalore
4 Bala M 31 Sales 1990-03-23 27000 NULL
5 Rani F 28 Marketing 1990-04-23 27000 Mumbai
6 Nisha F 26 NULL 1991-02-24 18000 Bangalore
7 Manoj M 32 Finance 1982-05-06 30000 Goa
(a) Write a Query to Display Employees’ name and City from the above table.
SELECT NAME, CITY FROM INFO;
Output:
(b) Write a Query to Display all details of Employees who are living in Chennai.
SELECT * FROM INFO WHERE CITY='CHENNAI';
Output:
30
(c) Write a Query to get the name and salary of the employee whose salary is above
15000 and gender is not male.
SELECT NAME,SALARY FROM INFO WHERE SALARY >15000 AND GENDER<>'M';
Output:
(d) Write a query to update increase 10% Salary of an employee whose City is 'CHENNAI'
and Gender is 'MALE'.
UPDATE INFO SET SALARY=SALARY+ (SALARY*0.10) WHERE
CITY='CHENNAI' AND GENDER='MALE';
Output (After Updating):
(e) Write a Query to delete the details of Employee Id 6.
DELETE FROM INFO WHERE EMPID=6;
Output (After Deletion):
*************************************************************************
31
Ex.No: 23
DATE:
SQL COMMANDS EXERCISE – 3
(Aggregate Functions, Order By Group By, Havning Clause)
AIM:
To write Queries for the following Questions based on the given table:
EmpID Name Gender Age Dept DOJ Salary City
1 Praveen M 25 Sales 1989-06-08 20000 Chennai
2 Arun M 29 Marketing 1989-09-26 22000 Chennai
3 Usha F 27 Finance 1994-08-09 25000 Bangalore
4 Bala M 31 Sales 1990-03-23 27000 NULL
5 Rani F 28 Marketing 1990-04-23 27000 Mumbai
6 Nisha F 26 NULL 1991-02-24 18000 Bangalore
7 Manoj M 32 Finance 1982-05-06 30000 Goa
(a) Write a Query to list names of Employees in Descending order.
SELECT NAME FROM INFO ORDER BY NAME DESC;
Output:
(b) Write a Query to find a total salary of all employees.
SELECT SUM(SALARY) FROM INFO;
Output:
(c) Write a Query to display maximum salary and minimum salary of employees.
SELECT MAX(SALARY), MIN(SALARY) FROM INFO;
Output:
32
(d) Write a Query to count the number of employees earning more than 25000.
SELECT COUNT(SALARY) FROM INFO WHERE SALARY>25000;
Output:
(e) Write a query to display sum of salary of the employees grouped by department wise.
SELECT DEPT, SUM(SALARY) FROM INFO GROUP BY DEPT;
Output:
(f) Write a query to display the department names where number of employees are
greater than or equal to 2.
SELECT DEPT FROM INFO GROUP BY DEPT HAVING COUNT(*)>=2;
Output:
****************************************************************************************
33
Ex.No: 24
DATE:
SQL COMMANDS EXERCISE – 4
(Mathematical Functions)
AIM:
To write Queries for the following Questions based on the given table -"STU":
(a) Write a Query to Display square of age that got admission in the month of August.
SELECT POWER(AGE,2) FROM STU WHERE DOA LIKE '%-08-%';
Output:
(b) Write a Query to display Remainder of column Percentage divide by 3.
SELECT MOD(MARKS,3) FROM STU;
Output:
34
(c) Write a Query to display Student names and their Percentage in round figure.
SELECT NAME, ROUND(PERCENTAGE,0) FROM STU;
Output:
(d) Display Name, Percentage and round up the remainder marks up to 2 decimal
places.
SELECT NAME, ROUND(MOD(PERCENTAGE,3),2) FROM STU;
Output:
**************************************************************************************
35
Ex.No: 25
DATE:
SQL COMMANDS EXERCISE – 5
(Text Functions)
AIM:
To write Queries for the following Questions based on the given table -"STU":
(a) Write a Query to display Department name in lower case letters.
SELECT LCASE(DEPT) FROM STU;
Output:
(b) Write a Query to display department name and its respective number of characters
in Dept column.
SELECT DEPT,LENGTH(DEPT) FROM STU;
Output:
36
(c) Write a Query to display first 2 characters of the column Name.
SELECT LEFT(NAME,2) FROM STU;
Output:
(d) Write a Query to display first 2 characters of the column Name.
SELECT RIGHT(NAME,2) FROM STU;
Output:
(e) Write a query to display the names of all students and extract five characters from the
third position of the 'Name' field.
SELECT SUBSTR(NAME,3,5) FROM STU;
Output:
**********************************************************************************************
37
Ex.No: 26
DATE:
SQL COMMANDS EXERCISE – 6 (Date Functions)
AIM:
To write Queries for the following Questions based on the given table:
(a) Write a Query to display student name and month of date of admission of all
students.
SELECT NAME, MONTH(DOA) FROM STU;
Output:
(b) Write a Query to display Student name and day name of the students’ DOA of the
table STU.
SELECT NAME, DAYNAME(DOA) FROM STU;
Output:
38
(c) Write a query to display the joining year of IP students.
SELECT YEAR(DOA) FROM STU WHERE DEPT='IP'
Output:
(d) Write a Query to Display the month for the date_of_birth of all students.
SELECT NAME, MONTHNAME(DOA)FROM STU;
Output:
(e) Write a query to display the names of the students who joined in the month of June.
SELECT NAME FROM STU WHERE MONTHNAME(DOA)='June';
Output:
*********************************************************************************************

More Related Content

PPT
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
PPT
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
DOCX
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
PPTX
TO DO APP USING STREAMLIT PYTHON PROJECT
PDF
CorePy High-Productivity CellB.E. Programming
PDF
Python Essentials For Dummies John C Shovic Alan Simpson
DOCX
COMP 122 Entire Course NEW
DOC
Cis 170 c ilab 5 of 7 arrays and strings
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
TO DO APP USING STREAMLIT PYTHON PROJECT
CorePy High-Productivity CellB.E. Programming
Python Essentials For Dummies John C Shovic Alan Simpson
COMP 122 Entire Course NEW
Cis 170 c ilab 5 of 7 arrays and strings

Similar to CLASS 12 IP PRACTICAL PROGRAMS 2024-25.pdf (20)

DOC
Devry cis 170 c i lab 5 of 7 arrays and strings
DOC
Devry cis 170 c i lab 5 of 7 arrays and strings
PDF
Tutorial_Python1.pdf
PDF
Enviropy Environmental Science With Python Van Der Post Hayden
PDF
Devry cis 170 c i lab 5 of 7 arrays and strings
DOC
Cis 247 all i labs
DOC
Gsp 215 Enhance teaching-snaptutorial.com
PPTX
Data-Analytics using python (Module 4).pptx
DOC
Gsp 215 Believe Possibilities / snaptutorial.com
PDF
GraphQL Advanced
PDF
DOC
Cis247 i lab 3 overloaded methods and static methods variables
DOC
Cis247 a ilab 3 overloaded methods and static methods variables
DOCX
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docx
DOCX
Wmc lab (1)
DOC
Cis247 a ilab 3 overloaded methods and static methods variables
PDF
C++ Lab Maual.pdf
PDF
C++ Lab Maual.pdf
PDF
Key projects Data Science and Engineering
PDF
Key projects Data Science and Engineering
Devry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and strings
Tutorial_Python1.pdf
Enviropy Environmental Science With Python Van Der Post Hayden
Devry cis 170 c i lab 5 of 7 arrays and strings
Cis 247 all i labs
Gsp 215 Enhance teaching-snaptutorial.com
Data-Analytics using python (Module 4).pptx
Gsp 215 Believe Possibilities / snaptutorial.com
GraphQL Advanced
Cis247 i lab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variables
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docx
Wmc lab (1)
Cis247 a ilab 3 overloaded methods and static methods variables
C++ Lab Maual.pdf
C++ Lab Maual.pdf
Key projects Data Science and Engineering
Key projects Data Science and Engineering
Ad

Recently uploaded (20)

PPTX
Unit 4 Computer Architecture Multicore Processor.pptx
PDF
English Textual Question & Ans (12th Class).pdf
PDF
Environmental Education MCQ BD2EE - Share Source.pdf
PDF
Empowerment Technology for Senior High School Guide
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PDF
Mucosal Drug Delivery system_NDDS_BPHARMACY__SEM VII_PCI.pdf
PDF
Complications of Minimal Access-Surgery.pdf
PDF
Hazard Identification & Risk Assessment .pdf
PDF
Race Reva University – Shaping Future Leaders in Artificial Intelligence
PDF
International_Financial_Reporting_Standa.pdf
PPTX
Share_Module_2_Power_conflict_and_negotiation.pptx
PDF
MICROENCAPSULATION_NDDS_BPHARMACY__SEM VII_PCI .pdf
PDF
Uderstanding digital marketing and marketing stratergie for engaging the digi...
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PDF
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
PDF
HVAC Specification 2024 according to central public works department
PDF
LEARNERS WITH ADDITIONAL NEEDS ProfEd Topic
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
PDF
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
PDF
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
Unit 4 Computer Architecture Multicore Processor.pptx
English Textual Question & Ans (12th Class).pdf
Environmental Education MCQ BD2EE - Share Source.pdf
Empowerment Technology for Senior High School Guide
FORM 1 BIOLOGY MIND MAPS and their schemes
Mucosal Drug Delivery system_NDDS_BPHARMACY__SEM VII_PCI.pdf
Complications of Minimal Access-Surgery.pdf
Hazard Identification & Risk Assessment .pdf
Race Reva University – Shaping Future Leaders in Artificial Intelligence
International_Financial_Reporting_Standa.pdf
Share_Module_2_Power_conflict_and_negotiation.pptx
MICROENCAPSULATION_NDDS_BPHARMACY__SEM VII_PCI .pdf
Uderstanding digital marketing and marketing stratergie for engaging the digi...
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
HVAC Specification 2024 according to central public works department
LEARNERS WITH ADDITIONAL NEEDS ProfEd Topic
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
Ad

CLASS 12 IP PRACTICAL PROGRAMS 2024-25.pdf

  • 1. 2 TABLE OF CONTENTS S.No Name of the Exercises Page.No Programs using Pandas SERIES 1. Creating a Python program to create a series using a dictionary. 3 2. Creating a Python program to create a series using scalar value. 4 3. Creating a Python program to create a series using NumPy array. 5 4. Creating a python program for modifying or updating existing values of series object. 6 5. Creating a Python program for performing mathematical operations on two Series objects. 7 6. Creating a Python program for calculating per capita income of four zones using Series. 8 7. Creating a Python program to display attributes of a Series. 9 8. Creating a Python program using head() and tail() in Series. 10 DATAFRAME 9. Creating a Python program for creating a DataFrame using a nested list. 11 10. Creating a python program for accessing values of rows and columns of a dataframe. 12 11. Creating a Python program for accessing values of rows and columns of a DataFrame. 14 12. Creating a python program to perform operations on a DataFrame (rename, count, update, replace) 16 13. Creating a Python program to filter the data of a DataFrame. 18 14. Creating a Python program to display the attributes of the DataFrame. 19 15. Creating a Python program to display the data of a DataFrame row-wise and column-wise using iterrows() and iteritems() 20 16. Creating a Python program to perform writing and reading operations in a CSV file. 22 Programs using Matplotlib – Data Visualization 17. Creating a python program for plotting a line chart. 23 18. Creating a python program for plotting a bar chart from a CSV file. 24 19. Creating a python program for plotting a multiple bar chart from a CSV file. 25 20. Creating a python program for plotting Histogram. 26 SQL Queries 21. SQL COMMANDS EXERCISE – 1 (Basic Queries – I) 27 22. SQL COMMANDS EXERCISE – 2 (Basic Queries – II) 29 23. SQL COMMANDS EXERCISE – 3 (Aggregate functions, Order by Group by, Having Clause) 31 24. SQL COMMANDS EXERCISE – 4 (Math Functions) 33 25. SQL COMMANDS EXERCISE – 5 (Text Functions) 35 26. SQL COMMANDS EXERCISE – 6 (Date Functions) 37
  • 2. 3 EX.NO: 1 DATE: CREATING A PYTHON PROGRAM TO CREATE A SERIES USING A DICTIONARY. AIM: To write a Python program to create a Series to store 5 students Percentage Using dictionary and print all the elements that are above 75 percentage. SOURCE CODE: RESULT: Thus, the above Python program has been executed successfully, and the output has been verified. SAMPLE OUTPUT: ************************************************************************************************
  • 3. 4 EX.NO: 2 DATE: CREATING A PYTHON PROGRAM TO CREATE A SERIES USING SCALAR VALUE AIM: To write a Python program to create a Series object that stores the Initial budget allocated (50000/- each) for the four quarters of the year: Qtr1, Qtr2, Qtr3 and Qtr4. SOURCE CODE: RESULT: Thus, the above Python program has been executed successfully, and the output has been verified. SAMPLE OUPUT:
  • 4. 5 EX.NO: 3 DATE: CREATING A PYTHON PROGRAM TO CREATE A SERIES USING NUMPY ARRAY AIM: To write a Python program to create a Series object that stores the Employee names as index and their Salary as values SOURCE CODE: RESULT: Thus, the above Python program has been executed successfully, and the output has been verified. SAMPLE OUTPUT: *************************************************************************************************
  • 5. 6 EX.NO: 4 DATE: CREATING A PYTHON PROGRAM FOR MODIFYING OR UPDATING EXISTING VALUES OF SERIES OBJECT. AIM: To Write a Python program to create a Series object with Employee names as the index and their salaries as values. Accept the name of the employee whose salary needs to be changed, along with the new salary, and update it in the Series. Source Code: RESULT: Thus, the above Python program has been executed successfully, and the output has been verified. Sample Output: ****************************************************************************************
  • 6. 7 EX.NO: 5 DATE: CREATING A PYTHON PROGRAM FOR PERFORMING MATHEMATICAL OPERATIONS ON TWO SERIES OBJECTS AIM: To create a program in python to perform following mathematical Operations on Two Series objects: (i) Addition (ii) Subtraction (iii) Multiplication (iv) Division. SOURCE CODE: RESULT: Thus, the above Python program has been executed successfully, and the output has been verified. SAMPLE OUTPUT: **************************************************************************************************
  • 7. 8 EX.NO: 6 DATE: CREATING A PYTHON PROGRAM FOR CALCULATING PER CAPITA INCOME OF FOUR ZONES USING SERIES AIM: To write a Python program to create two series i.e. population and average income of Four Zones, and then calculate per capita income storing in third pandas series print it. Source Code: RESULT: Thus, the above Python program has been executed successfully, and the output has been verified. Sample Output: ***************************************************************************************
  • 8. 9 EX.NO: 7 DATE: CREATING A PYTHON PROGRAM TO DISPLAY ATTRIBUTES OF A SERIES AIM: To write a Python program to create a Series using list and display the following attributes of the Series: (i) index (ii) dtype (iii) size (iv) shape (v) hasnans SOURCE CODE: RESULT: Thus, the above Python program has been executed successfully, and the output has been verified. SAMPLE OUTPUT: *************************************************************************************************
  • 9. 10 EX.NO: 8 DATE: CREATING A PYTHON PROGRAM USING head() AND tail() IN SERIES AIM: To write a Python program to create a Series using list of Marks of 10 students and display first 5 Students’ marks and Last 2 Students’ marks from Series object. SOURCE CODE: RESULT: Thus, the above Python program has been executed successfully, and the output has been verified. SAMPLE OUTPUT: **************************************************************************************************
  • 10. 11 EX.NO: 9 DATE: CREATING A PYTHON PROGRAM FOR CREATING A DATAFRAME USING A NESTED LIST AIM: To write a Python program to create a panda’s Data Frame for the following table Using Nested list: SOURCE CODE: RESULT: Thus, the above Python program has been executed successfully, and the output has been verified. SAMPLE OUTPUT: **************************************************************************************************
  • 11. 12 EX.NO: 10 DATE: CREATING A PYTHON PROGRAM FOR ACCESSING VALUES OF ROWS AND COLUMNS OF A DATAFRAME AIM: To write a Python program to create a panda’s DataFrame called DF for the following table Using Dictionary of List and perform the following operations: (i) To Display only column 'Toys' from DataFrame DF. (ii) To Display the row details of 'AP' and 'OD' from DataFrame DF. (iii) To Display the column 'Books' and 'Uniform' for 'M.P' and 'U.P' from DataFrame DF. (iv) To Display consecutive 3 rows and 3 columns from DataFrame DF. SOURCE CODE: RESULT: Thus, the above Python program has been executed successfully, and the output has been verified.
  • 13. 14 EX.NO: 11 DATE: CREATING A PYTHON PROGRAM FOR ACCESSING VALUES OF ROWS AND COLUMNS OF A DATAFRAME AIM: To write a Python program to create a panda’s DataFrame called DF for the following table Using Dictionary of List and perform the following operations: (i) Insert a new column “Bags” with values as [5891, 8628, 9785, 4475]. (ii) Delete the row details of M.P from DataFrame DF. SOURCE CODE: RESULT: Thus, the above Python program has been executed successfully, and the output has been verified.
  • 15. 16 EX.NO: 12 DATE: CREATING A PYTHON PROGRAM TO PERFORM OPERATIONS ON A DATAFRAME (RENAME, COUNT, UPDATE, REPLACE) AIM: To write a Python program to create a pandas DataFrame to analyze number of Government and Private medical college and their Total seats,Fees statewise details using the dataset available at www.data.gov.in. Also, perform the following operations. (i) To Change the name of the state AP to Andhra. (ii) To Count and Display Non-NaN values of each column. (iii) To Count and Display Non-NaN values of each row. (iv) To Increase the fees of all colleges by 5% (v) To Replace all NaN values with 0. Source Code: RESULT: Thus, the above Python program has been executed successfully, and the output has been verified.
  • 17. 18 EX.NO: 13 DATE: CREATING A PYTHON PROGRAM TO FILTER THE DATA OF A DATAFRAME AIM: To write a Python program to create a panda’s DataFrame called DF for the following table using Dictionary of List and display the details of students whose Percentage is more than 85. SOURCE CODE: RESULT: Thus, the above Python program has been executed successfully, and the output has been verified. SAMPLE OUTPUT: *******************************************************************************************
  • 18. 19 EX.NO: 14 DATE: CREATING A PYTHON PROGRAM TO DISPLAY THE ATTRIBUTES OF A DATAFRAME AIM: To write a Python program to create a DataFrame using Dictionary of list and display the following attributes of the DataFrame: (i) index (ii) columns (iii) axes (iv) dtypes (v) shape (vi) dimension (vii) T SOURCE CODE: RESULT: Thus, the above Python program is executed successfully and the output is verified. SAMPLE OUTPUT: *******************************************************************************************
  • 19. 20 EX.NO: 15 DATE: CREATING A PYTHON PROGRAM TO DISPLAY THE DATA OF A DATAFRAME ROW-WISE AND COLUMN-WISE USING ITERROWS() AND ITERITEMS() AIM: To write a Python program to create a panda’s DataFrame called Students for the following table and demonstrate iterrows and iteritems. SOURCE CODE: RESULT: Thus, the above Python program has been executed successfully, and the output has been verified.
  • 20. 21 SAMPLE OUTPUT: # Output for Iterrows() # Output for Iteritems() **********************************************************************************************
  • 21. 22 EX.NO: 16 DATE: CREATING A PYTHON PROGRAM TO PERFORM WRITING AND READING OPERATIONS IN A CSV FILE AIM: To Write a Python program to store the details of Employess’ such as Empno, Name, Salary into a Employee.csv file. Also, write a code to read employee details from csv file. SOURCE CODE: RESULT: Thus, the above Python program has been executed successfully, and the output has been verified. SAMPLE OUTPUT: **********************************************************************************************
  • 22. 23 EX.NO: 17 DATE: CREATING A PYTHON PROGRAM FOR PLOTTING A LINE CHART AIM: To write a Python program to plot a Line chart to depict the changing weekly Onion and Brinjal prices for four weeks. Also, give appropriate axes labels, title and keep marker style as Diamond and marker edge color as ‘red’ for Onion. SOURCE CODE: RESULT: Thus, the above Python program has been executed and verified successfully, and its respective chart has been generated successfully. SAMPLE OUTPUT: *********************************************************************************************
  • 23. 24 EX.NO: 18 DATE: CREATING A PYTHON PROGRAM FOR PLOTTING A BAR CHART FROM A CSV FILE AIM: To write a Python program to create a DataFrame for subject-wise average, save it to a CSV file, and then draw a bar chart using Matplotlib with a width of each bar as 0.25, specifying different colors for each bar. Additionally, provide a proper title and axes labels for the bar chart. Source Code: RESULT: Thus, the above Python program has been executed and verified successfully, and its respective chart has been generated successfully. Sample Output: ***********************************************************************************************
  • 24. 25 EX.NO: 19 DATE: CREATING A PYTHON PROGRAM FOR PLOTTING A MULTIPLE BAR CHART FROM A CSV FILE AIM: To write a Python program to plot a multiple bar chart From CSV file using Matplotlib for subject wise Scores of Class A, Class B, and Class C. Different colors represent each class, and subjects include English,Accountancy,Economics,BST and IP. Proper labels, a title and a legend are displayed on the chart. Source Code: RESULT: Thus, the above Python program has been executed and verified successfully, and its respective chart has been generated successfully. Sample Output: *****************************************************************************************************
  • 25. 26 EX.NO: 20 DATE: CREATING A PYTHON PROGRAM FOR PLOTTING PLOTTING HISTOGRAM AIM: To write a Python program to plot a Histogram for the following class interval or range. Also, give appropriate axes name, title and edege color as ‘red’. SOURCE CODE: RESULT: Thus, the above Python program has been executed and verified successfully, and the respective chart has been generated successfully. SAMPLE OUTPUT: ******************************************************************************************
  • 26. 27 Ex.No: 21 DATE: SQL COMMANDS EXERCISE – 1 (Basic Queries – I) AIM: To write Queries for the following Questions based on the given table: EmpID Name Gender Age Dept DOJ Salary City 1 Praveen M 25 Sales 1989-06-08 20000 Chennai 2 Arun M 29 Marketing 1989-09-26 22000 Chennai 3 Usha F 27 Finance 1994-08-09 25000 Bangalore 4 Bala M 31 Sales 1990-03-23 27000 NULL 5 Rani F 28 Marketing 1990-04-23 27000 Mumbai 6 Nisha F 26 NULL 1991-02-24 18000 Bangalore 7 Manoj M 32 Finance 1982-05-06 30000 Goa (a) Write a Query to Create a new database in the name of "EMPS". CREATE DATABASE EMPS; (b) Write a Query to Open the database EMPS. USE EMPS; (c) Write a Query to create the above table called: Info CREATE TABLE INFO (EmpID int primary key, Name varchar(15), Gender varchar(3),Age int,Dept varchar(15),DOJ date, Salary int, City varchar(10)); (d) Write a Query to list all the existing database names. SHOW DATABASES;
  • 27. 28 (e) Write a Query to List all the tables that exists in the current database. SHOW TABLES; Output: (f) Write a Query to insert all the rows of above table into Info table. INSERT INTO INFO VALUES (1,'Praveen','M', 25,'Sales','1989-06-08','20000','Chennai'); INSERT INTO INFO VALUES(2,'Arun','M',29,'Marketing','1989-09-26',22000,'Chennai'); INSERT INTO INFO VALUES(3,'Usha','F',27,'Finance','1994-08-09',25000,'Bangalore'); INSERT INTO INFO VALUES(4,'Bala','M',31,'Sales','1990-03-23',27000,NULL); INSERT INTO INFO VALUES(5,'Rani','F',28,'Marketing','1990-04-23',27000,'Mumbai'); INSERT INTO INFO VALUES (6,'Nisha','F', 26, NULL,'1991-02-24', 18000,'Bangalore'); INSERT INTO INFO VALUES (7,'Manoj','M', 32,'Finance','1982-05-06', 30000,'Goa'); (g) Write a Query to display all the details of the Employees from the above table 'INFO'. SELECT * FROM INFO; Output: ****************************************************************************************************
  • 28. 29 Ex.No: 22 DATE: SQL COMMANDS EXERCISE – 2 (Basic Queries – II) AIM: To write Queries for the following Questions based on the given table: EmpID Name Gender Age Dept DOJ Salary City 1 Praveen M 25 Sales 1989-06-08 20000 Chennai 2 Arun M 29 Marketing 1989-09-26 22000 Chennai 3 Usha F 27 Finance 1994-08-09 25000 Bangalore 4 Bala M 31 Sales 1990-03-23 27000 NULL 5 Rani F 28 Marketing 1990-04-23 27000 Mumbai 6 Nisha F 26 NULL 1991-02-24 18000 Bangalore 7 Manoj M 32 Finance 1982-05-06 30000 Goa (a) Write a Query to Display Employees’ name and City from the above table. SELECT NAME, CITY FROM INFO; Output: (b) Write a Query to Display all details of Employees who are living in Chennai. SELECT * FROM INFO WHERE CITY='CHENNAI'; Output:
  • 29. 30 (c) Write a Query to get the name and salary of the employee whose salary is above 15000 and gender is not male. SELECT NAME,SALARY FROM INFO WHERE SALARY >15000 AND GENDER<>'M'; Output: (d) Write a query to update increase 10% Salary of an employee whose City is 'CHENNAI' and Gender is 'MALE'. UPDATE INFO SET SALARY=SALARY+ (SALARY*0.10) WHERE CITY='CHENNAI' AND GENDER='MALE'; Output (After Updating): (e) Write a Query to delete the details of Employee Id 6. DELETE FROM INFO WHERE EMPID=6; Output (After Deletion): *************************************************************************
  • 30. 31 Ex.No: 23 DATE: SQL COMMANDS EXERCISE – 3 (Aggregate Functions, Order By Group By, Havning Clause) AIM: To write Queries for the following Questions based on the given table: EmpID Name Gender Age Dept DOJ Salary City 1 Praveen M 25 Sales 1989-06-08 20000 Chennai 2 Arun M 29 Marketing 1989-09-26 22000 Chennai 3 Usha F 27 Finance 1994-08-09 25000 Bangalore 4 Bala M 31 Sales 1990-03-23 27000 NULL 5 Rani F 28 Marketing 1990-04-23 27000 Mumbai 6 Nisha F 26 NULL 1991-02-24 18000 Bangalore 7 Manoj M 32 Finance 1982-05-06 30000 Goa (a) Write a Query to list names of Employees in Descending order. SELECT NAME FROM INFO ORDER BY NAME DESC; Output: (b) Write a Query to find a total salary of all employees. SELECT SUM(SALARY) FROM INFO; Output: (c) Write a Query to display maximum salary and minimum salary of employees. SELECT MAX(SALARY), MIN(SALARY) FROM INFO; Output:
  • 31. 32 (d) Write a Query to count the number of employees earning more than 25000. SELECT COUNT(SALARY) FROM INFO WHERE SALARY>25000; Output: (e) Write a query to display sum of salary of the employees grouped by department wise. SELECT DEPT, SUM(SALARY) FROM INFO GROUP BY DEPT; Output: (f) Write a query to display the department names where number of employees are greater than or equal to 2. SELECT DEPT FROM INFO GROUP BY DEPT HAVING COUNT(*)>=2; Output: ****************************************************************************************
  • 32. 33 Ex.No: 24 DATE: SQL COMMANDS EXERCISE – 4 (Mathematical Functions) AIM: To write Queries for the following Questions based on the given table -"STU": (a) Write a Query to Display square of age that got admission in the month of August. SELECT POWER(AGE,2) FROM STU WHERE DOA LIKE '%-08-%'; Output: (b) Write a Query to display Remainder of column Percentage divide by 3. SELECT MOD(MARKS,3) FROM STU; Output:
  • 33. 34 (c) Write a Query to display Student names and their Percentage in round figure. SELECT NAME, ROUND(PERCENTAGE,0) FROM STU; Output: (d) Display Name, Percentage and round up the remainder marks up to 2 decimal places. SELECT NAME, ROUND(MOD(PERCENTAGE,3),2) FROM STU; Output: **************************************************************************************
  • 34. 35 Ex.No: 25 DATE: SQL COMMANDS EXERCISE – 5 (Text Functions) AIM: To write Queries for the following Questions based on the given table -"STU": (a) Write a Query to display Department name in lower case letters. SELECT LCASE(DEPT) FROM STU; Output: (b) Write a Query to display department name and its respective number of characters in Dept column. SELECT DEPT,LENGTH(DEPT) FROM STU; Output:
  • 35. 36 (c) Write a Query to display first 2 characters of the column Name. SELECT LEFT(NAME,2) FROM STU; Output: (d) Write a Query to display first 2 characters of the column Name. SELECT RIGHT(NAME,2) FROM STU; Output: (e) Write a query to display the names of all students and extract five characters from the third position of the 'Name' field. SELECT SUBSTR(NAME,3,5) FROM STU; Output: **********************************************************************************************
  • 36. 37 Ex.No: 26 DATE: SQL COMMANDS EXERCISE – 6 (Date Functions) AIM: To write Queries for the following Questions based on the given table: (a) Write a Query to display student name and month of date of admission of all students. SELECT NAME, MONTH(DOA) FROM STU; Output: (b) Write a Query to display Student name and day name of the students’ DOA of the table STU. SELECT NAME, DAYNAME(DOA) FROM STU; Output:
  • 37. 38 (c) Write a query to display the joining year of IP students. SELECT YEAR(DOA) FROM STU WHERE DEPT='IP' Output: (d) Write a Query to Display the month for the date_of_birth of all students. SELECT NAME, MONTHNAME(DOA)FROM STU; Output: (e) Write a query to display the names of the students who joined in the month of June. SELECT NAME FROM STU WHERE MONTHNAME(DOA)='June'; Output: *********************************************************************************************