0% found this document useful (0 votes)
12 views54 pages

Imon Practical Info

The document is a practical file for Informatics Practices submitted by Cdt. Imon Ghosh at Rashtriya Indian Military College for the January term of 2025. It includes a list of experiments involving Python programming, data analysis using Pandas, and SQL queries, covering topics such as data visualization, DataFrame manipulation, and database operations. Each experiment outlines specific tasks, expected outputs, and coding requirements.

Uploaded by

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

Imon Practical Info

The document is a practical file for Informatics Practices submitted by Cdt. Imon Ghosh at Rashtriya Indian Military College for the January term of 2025. It includes a list of experiments involving Python programming, data analysis using Pandas, and SQL queries, covering topics such as data visualization, DataFrame manipulation, and database operations. Each experiment outlines specific tasks, expected outputs, and coding requirements.

Uploaded by

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

RASHTRIYA INDIAN MILITARY COLLEGE, JANUARY TERM, 2025

PRACTICAL FILE

Informatics Practices

Submitted To Submitted By
Manoj Kumar Nama Name: Cdt. Imon Ghosh
Roll No: 3271/S
Index
List of Experiments

S No Name of Experiment Page No


Practical Assignment

EXPERIMENT NO.1:
Given an ndarray p as ([1, 2, 3, 4]). Write code to plot a bar chart having bars for p
and p**2 (with red colour) and another bar for p and p*2 (with blue colour).

ANS 1.

OUTPUT:
EXPERIMENT NO. 2:
Shubham, a Data Analyst with a multinational brand has designed the DataFrame
df that contains the four quarters' sales data of different stores as shown below :

Answer the following questions :


(i) Predict the output of the following Python statement :
(a) print(df.size)
(b) print(df[1:3])
(ii) Delete the last row from the DataFrame.
(ii) Write Python statement to add a new column Total_Sales which is the
addition of all the 4 quarter sales.

ANS 2.

(i)

OUTPUT :
(ii)

OUTPUT :

(iii)

OUTPUT :

(iv)

OUTPUT:

EXPERIMENT NO. 2:
Create an array, A, in the range 1 to 20 with values 1.25 apart. Another array,
B, contains the log values of the elements in the array A.
Write a program to create a scatter plot of first vs. second array (array A vs. B)
with red circle markers; specify the x-axis (containing first array’s values) title
as ‘Random Values’ and y-axis title as ‘Logarithm Values’.
ANS 3.

OUTPUT:
Experiment No. 4:
Write a program to iterate over a dataframe containing names and marks which
then calculates grades as per marks(as per guiding below) and adds them to the
grade column.
Marks>= 95 grade A+ ; Marks 50-60 grade C;
Marks 70-90 grade A ; Marks 40-50 grade D;
Marks 60-70 grade B ; Marks <40 grade F

ANS 4.
OUTPUT:

Experiment No. 5:
Given a series nfib that contains reversed Fibonacci numbers with Fibonacci
numbers as shown below:
[0, -1, -1, -2, -3, -5, -8, -13, -21, -34, 0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
Write a program to plot nfib with following specifications:
(a) The line color should be magenta.
(b) The marker edge color should be black with size 5.
(c) Grid should be displayed.

ANS 5.
Experiment No. 6:
Write a program to create three different Series objects from the three rows of a
DataFrame df.

ANS 6.
OUTPUT:
Experiment No. 7:

Experiment No. 8:
PQR is a list having three lists inside it. It contains summarized data of three
different trials conducted by company A. create a bar chart that plots these three
sublists of ABC in a single chart. Keep the width of each bar as 0.25.
XYZ = [[5, 25, 45, 20], [4, 23, 49, 17], [6, 22, 47, 19]]

Experiment No. 9:
ANS 8.

OUTPUT:
Experiment No. 10:
Write a python program to draw line charts from the given financial data of
XYZ Co. for 5 days in the form a DataFrame namely fdf as shown below:

Day1 Day2 Day3 Day4


Day5
0 74.25 56.03 59.30 69.00
89.65
1 76.06 68.71 72.07 78.47
79.65
2 69.50 62.89 77.65 65.53
80.75
3 72.55 56.42 66.46 76.85
85.08

ANS 10.
OUTPUT:

Experiment No. 11:


Write a Pandas program to convert a dictionary to a Pandas series.
Sample dictionary: d1 = {'a': 100, 'b': 200, 'c':300}

ANS 11.
OUTPUT:

Experiment No. 12:


Write a program to print a DataFrame one row at a time and print only first five
rows.

Ans 12.

OUTPUT:
Experiment No. 13:
ANS 13.

OUTPUT:

Experiment No. 14:


ANS 14.

OUTPUT:
Experiment No. 15:

ANS 15.
OUTPUT:
Experiment No. 16:

ANS 16.

OUTPUT:
Experiment No. 17:
ANS 17.
(i)

OUTPUT:

(ii)

OUTPUT:

(iii)

OUTPUT:

(iv)

(v)

OUTPUT:
Experiment No. 18:
Write Python code to create a Series object Temp2 storing temperatures of seven
days of week. Its indexes should be 'Sunday', 'Monday',... 'Saturday'.
ANS 18.

OUTPUT:

Experiment No. 19:


Create a panda’s series from a dictionary of values and a ndarray.

ANS 19.
OUTPUT:

Experiment No. 20: Consider the following tables

Apply the Referential Integrity Constraint(ON DELETE CASCADE & ON DELETE SET
NULL) between above table, and answer the following queries.
When we delete civil department from Department Table then what will be the
effect on both tables.
ANS 20.

CASE I: ON DELETE CASCADE

If the Referential Integrity Constraint is set with ON DELETE CASCADE, it


means that when a row is deleted from the parent table (DEPARTMENT), all cor-
responding rows in the child table (EMPLOYEE) that have a matching foreign
key value will also be automatically deleted.

In this case, when we delete the 'civil' department (where DeptID is 'D101') from
the DEPARTMENT table, the EMPLOYEE table will be affected as follows:

 The row where EID is 'E202' and DID is 'D101' (Ravi) will be deleted.
 The row where EID is 'E203' and DID is 'D101' (Krishnan) will also be de-
leted.
CASE II: ON DELETE SET NULL

If the Referential Integrity Constraint is set with ON DELETE SET NULL, it


means that when a row is deleted from the parent table (DEPARTMENT), the for-
eign key column (DID) in all corresponding rows in the child table (EMPLOYEE)
will be set to NULL. This is only possible if the DID column in the EMPLOYEE
table allows NULL values.

In this case, when we delete the 'civil' department (where DeptID is 'D101') from
the DEPARTMENT table, the EMPLOYEE table will be affected as follows:

 The row where EID is 'E202' and DID is 'D101' (Ravi) will have its DID
value changed to NULL.
 The row where EID is 'E203' and DID is 'D101' (Krishnan) will also have its
DID value changed to NULL.

Experiment No. 21: Consider the following table:

Write a query to Perform Equi Join between two tables.

ANS 21.

OUTPUT:
Experiment No. 22:
Consider the following tables CABHUB and CUSTOMER.

Write SQL commands for the following:


(a) To display the names of all the white colored vehicles.
(b) To display name of vehicle name and capacity of vehicles in ascending
order of their seating capacity.
(c) To display the highest charges at which a vehicle can be hired from
CABHUB.
(d) To display the customer’s name and the corresponding name of the
vehicle hired by them.

ANS 22.
(a)

OUTPUT:

(b)

OUTPUT:

(c)

OUTPUT:
(d)

OUTPUT:

Experiment No. 23:


Consider the following table GAME.

Write SQL Commands for the following statements:


(a) To display details of those GAMES which are having Prizemoney more than
7000.
(b) To display the content of the GAMES table in ascending order of Schedule
Date.
(c) To display the sum of Prizemoney for each type of GAMES.

ANS 23.
(a)

OUTPUT:

(b)

OUTPUT:

(c)

OUTPUT:

Experiment No. 24:


Write the UPDATE command to increase the commission (Column name : COMM)
by 500 of all the Salesmen who have achieved Sales (Column name : SALES) more
than 200000. The table's name is COMPANY.

ANS 24.

Experiment No. 25:


Based on the SQL table CAR_SALES, write suitable queries for the following :

(i) Display fuel wise average sales in the first quarter.


(ii) Display segment wise highest sales in the second quarter.
(iii) Display the records in the descending order of sales in the second quarter.
NUMBER SEGMENT FUEL QT1 QT2
1 Compact HatchBack Petrol 56000 70000
2 Compact HatchBack Diesel 34000 40000
3 MUV Petrol 33000 35000
4 MUV Diesel 14000 15000
5 SUV Petrol 27000 54000
6 SUV Diesel 18000 30000
7 Sedan Petrol 8000 10000
8 Sedan Diesel 1000 5000

ANS 25.

(i)

OUTPUT:
(ii)

OUTPUT:

(iii)

OUTPUT:

Experiment No. 26:


In a Database, there are two tables given below :
Write SQL Queries for the following :

a. To display employee ids, names of employees, job ids with corresponding job
titles.

b. To display names of employees, sales and corresponding job titles who have
achieved sales more than 1300000.

c.To display names and corresponding job titles of those employees who have
'SINGH' (anywhere) in their names.

d.Identify foreign key in the table EMPLOYEE.

e.Write SQL command to change the JOBID to 104 of the EMPLOYEE with ID as E4
in the table 'EMPLOYEE'.

ANS 26.

(a)

OUTPUT:

(b)
OUTPUT:

(c)

OUTPUT:

(d) The foreign key in the EMPLOYEE table is JOBID, which


references the JOBID in the JOB table.

(e)

Experiment No. 27:


In a Database Tamilnadu_Sangam there are two tables with the instances given
below :
Write SQL queries for the following :
(i) To count how many addresses are not having NULL values in the address
column of STUDENTS table.
(ii) To display Name, Class from STUDENTS table and the corresponding Grade
from SPORTS table.
(iii)To display Name of the student and their corresponding Coachnames from
STUDENTS and SPORTS tables.
ANS 27.

(i)

OUTPUT:

(ii)

OUTPUT:

(iii)
OUTPUT:

Experiment No. 28:


Write a SQL query to order the (student ID, marks) table in descending order of
the marks.

ANS 28.

Experiment No. 29:


Find the total number of customers from each country in the table (customer ID,
customer Name, country) using group by.

ANS 28.

Experiment No. 30:


Find the min, max, sum, and average of the marks in a student marks table.
ANS 30.

Experiment No. 31:


Consider the following table named “DRINK”.
DRINKCODE DNAME PRICE CALORIES
101 Lime and Lemon 20 120
102 Apple Drink 18 120
103 Nature Nectar 15 115
104 Green Mango 15 140
105 Aam Panna 20 135
106 Mango Juice Bahaar 12 150
Write commands of SQL for
To display names and drink codes of those drinks that have more than 120
calories.

ANS 31.

OUTPUT:

Experiment No. 32:


Project 1:
Titanic Data Analysis.
Note : The Titanic dataset we are using contains the names and information of
891 passengers on the Titanic, including whether they survived.

ANS 32(PROJECT 1).

OUTPUT:
GRAPH:

Project 2:
Covid 19 Data Analysis using CSV & Matplotlib.
 Dataset contain at least 500 data points.

ANS 32(PROJECT 2).


OUTPUT:

GRAPH:
Project 3:
# Importing and exporting data between pandas and CSV file.
# To create and open a data frame using ‘Student_result.csv’ file using Pandas.

# To display row labels, column labels data types of each column and the
dimensions
# To display the shape (number of rows and columns) of the CSV file.
# To display Adm_No, Gender and Percentage from ‘student_result.csv’ file.
# To display the first 5 and last 5 records from ‘student_result.csv’ file.
# To display Student_result file with new column names.
# To modify the Percentage of student below 35 with NaN value in dataframe.

ANS 32(PROJECT 3).

You might also like