Ip Practical 2024

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

10.

DataFrame (15/07/2024)
Iteration on Rows and Columns
iterrows ()

OUTPUT
11.CSV (20/07/2024)
12.DataFrame (22/07/2024)

iteritems ()

OUTPUT
13.DataFrame (24/07/2024)
Program for iteration
14.CSV (27/07/2024)
Write a program to read details such as Item, Sales made in a DataFrame and then store this
data in a CSV file.

SOURCE CODE

import pandas as pd

data = {'Item': ['Apple', 'Banana', 'Orange', 'Grapes'],'Sales': [100, 150, 80, 120]}

df = pd.DataFrame(data)

df.to_csv('one.csv', index = False)

Output

Item,Sales
Apple,100
Banana,150
Orange,80
Grapes,120
15.Bargraph(29/07/2024)

OUTPUT
16.LIne plot(31/07/2024)
A line plot/chart is a graph that shows the frequency of data occurring along a number line.
The line plot is represented by a series of datapoints connected with a straight line.
Generally line plots are used to display trends over time. A line plot or line graph can be
created using the plot() function available in pyplot library. We can, not only just plot a line
but we can explicitly define the grid, the x and y axis scale and labels, title and display options
etc
import numpy as np
import matplotlib.pyplot as plt
year = [2014,2015,2016,2017,2018]
jnvpasspercentage = [90,92,94,95,97]
kvpasspercentage = [89,91,93,95,98]
plt.plot(year, jnvpasspercentage, color='g')
plt.plot(year, kvpasspercentage, color='orange')
plt.xlabel(‘Year')
plt.ylabel('Pass percentage')
plt.title('JNV KV PASS % till 2018')
plt.show()
OUTPUT

Note:- As many lines required call plot() function multiple times with suitable
arguments.
17.Histogram(03/08/2024)
A histogram is a graphical representation which organizes a group of data points into user-
specified ranges.

Histogram provides a visual interpretation of numerical data by showing the number of data
points that fall within a specified range of values (“bins”). It is similar to a vertical bar graph
but without gaps between the bars.

SOURCE CODE

import numpy as np
import matplotlib.pyplot as plt
data = [1,11,21,31,41]
plt.hist([5,15,25,35,45, 55], bins=[0,10,20,30,40,50, 60], weights=[20,10,45,33,6,8],
edgecolor="red")
plt.show()
OUTPUT
18.Math Functions(05/08/2024)

With Definition , example and output

1. POWER ()
2. ROUND ()
3. MOD ()

19.Text Functions(07/08/2024)

1. UCASE ()/ UPPER ()


2. LCASE ()/ LOWER ()
3. MID ()/ SUBSTRING ()/SUBSTR ()
4. LENGTH ()
5. LEFT ()
6. RIGHT ()
7. INSTR ()
8. LTRIM ()
9. RTRIM ()
10. TRIM()

20.Date Functions(12/08/2024)

1. NOW ()
2. DATE ()
3. MONTH ()
4. MONTHNAME()
5. YEAR ()
6. DAY ()
7. DAYNAME()
21.Student Table (15 Queries) (14/08/2024)

Write SQL statements for the following based on table Garments:


1. Create above table in MySQL.
2. Insert records.
3. To display the detail of class XII students in descending order of their marks.
4. Display all the details of students in ascending order of name.
5. Find the maximum marks of the student for each class.
6. Count the students class wise is display only those number who is more than 2.
7. Display unique cities from the table.
8. Display minimum marks
9. Display Average marks
10. Display total number of students in the student table.
11. Display all records in discending

Solution:

1 Create table:

create table students


(rollno int(4) primary key,
name varchar(20) not null,
class varchar(4),
dob date,
gender char(1),
city varchar(20),
marks float);

2 Insert records:
insert into students values
(1, 'Naman', 'XII','1995/05/09','M','Anand',453)
Insert all records simimlarly.

3 display the detail of class XII students in descending order of their marks
select * from students order by marks desc;

4 Display all the details of students in ascending order of name


select * from students order by name asc

5 Find the maximum marks of the student for each class


select class,max(marks) from students group by class

6 Count the students class wise is display only those number who is more than 2
select class,count(*) from students group by class having count(*)>2;

7 Display unique cities from the table


select distinct city from students;

22.Employee Table(15 Queries)(17/08/2024)

(15 Queries and output)

23.Doctor & Salary (07 Queries)(21/08/2024)

(15 Queries and output)

24.Employees & Empsalary (07 Queries)(24/08/2024)

(15 Queries and output)


25.Books & Issued(07 Queries)(28/08/2024)

(15 Queries and output)

26.Furniture & Arrivals(07 Queries) (31/08/2024)

(15 Queries and output)

12 IP KV PANGODE /SKV

You might also like