0% found this document useful (0 votes)
30 views40 pages

Isbssjksa

Uploaded by

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

Isbssjksa

Uploaded by

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

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
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
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
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
EX.NO: 5
DATE:

PERFORMING MATHEMATICAL OPERATIONS ON 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
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
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
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
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
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.

12
SAMPLE OUTPUT:

*************************************************************************************************

13
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.

14
SAMPLE OUTPUT:

**************************************************************************************************

15
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.

16
Sample Output:

*************************************************************************************

17
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
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
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
SAMPLE OUTPUT:

# Output for Iterrows() # Output for Iteritems()

**********************************************************************************************

21
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
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
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
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
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
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:
PRATICAL 36
Problem statement: To display student id, Name, DOB, Marks, Email of those male students
in ascending order of their names.
STUDENT ID NAME DOB MARKS EMAIL
SCS101101 Rahil Khan 21/04/2000 450 [email protected]
SCS101102 Jitendal Pal 12/05/2001 499 [email protected]
SCS101103 Suman Lakra 19/05/2002 460 [email protected]
SCS101104 Chandumal Jain 24/06/2002 489 [email protected]

Solution:
Source Code:
SELECT STUDENT_ID, NAME, DOB, MARKS, EMAIL FROM STUDENT WHERE GENDER='M'
ORDER BY NAME;

Screenshot:
PRATICAL 37
Problem statement: Describe the below table
STUDENT ID NAME DOB MARKS EMAIL
SCS101101 Rahil Khan 21/04/2000 450 [email protected]
SCS101102 Jitendal Pal 12/05/2001 499 [email protected]
SCS101103 Suman Lakra 19/05/2002 460 [email protected]
SCS101104 Chandumal Jain 24/06/2002 489 [email protected]

Solution:
Source Code:
DESC STUDENT;

Screenshot:
PRATICAL 38
Problem statement: Display student name whose marks above 470.
STUDENT ID NAME DOB MARKS EMAIL
SCS101101 Rahil Khan 21/04/2000 450 [email protected]
SCS101102 Jitendal Pal 12/05/2001 499 [email protected]
SCS101103 Suman Lakra 19/05/2002 460 [email protected]
SCS101104 Chandumal Jain 24/06/2002 489 [email protected]

Solution:
Source Code:
SELECT NAME FROM STUDENT WHERE MARKS>470;

Screenshot:
PRATICAL 39
Problem statement: To display student id, Name, DOB of those students who are born
between ‘2000- 04-21’ and ‘2002-06-24’.
STUDENT ID NAME DOB MARKS EMAIL
SCS101101 Rahil Khan 21/04/2000 450 [email protected]
SCS101102 Jitendal Pal 12/05/2001 499 [email protected]
SCS101103 Suman Lakra 19/05/2002 460 [email protected]
SCS101104 Chandumal Jain 24/06/2002 489 [email protected]

Solution:
Source Code:
SELECT STUDENT_ID, NAME, DOB FROM STUDENT WHERE DOB BETWEEN '2000-04-21'
AND '2002-06-24';

Screenshot:
PRATICAL 40
Problem statement: To display student id, Gender, Name, DOB, Marks, Email in descending
order of their marks.
STUDENT NAME GENDER DOB MARKS EMAIL
ID
SCS101101 Rahil Khan M 21/04/2000 450 [email protected]
SCS101102 Jitendal Pal M 12/05/2001 499 [email protected]
SCS101103 Suman Lakra M 19/05/2002 460 [email protected]
SCS101104 Chandumal Jain M 24/06/2002 489 [email protected]

Solution:
Source Code:
SELECT STUDENT_ID, GENDER, NAME, DOB, MARKS, EMAIL FROM STUDENT ORDER BY
MARKS DESC;

Screenshot:

You might also like