Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
59 views38 pages

CBSE Class XII Informatics Practices Project

Ha cutctuxu

Uploaded by

Shweta
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)
59 views38 pages

CBSE Class XII Informatics Practices Project

Ha cutctuxu

Uploaded by

Shweta
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

DECLARATION

I <your name>, bearing roll no <your no>, a student of Class XII,


Leelawati Public School, hereby declare that I own the full
responsibility for the information, results etc. Provided in this
Practical File. It has been created successfully by using the Database
Tool MysSQL and SQL commands at <your school name> in
complete fulfillment of practical (curriculum of Central Board of
Secondary Education CBSE of Informatics Practices (065) conducted
by CBSE, New Delhi for the academic session 2024- 25.

<your name>
Roll No:
Class: XII
Leelawati Public School
CERTIFICATE

This is to certify that the Informatics Practices (065) Practical


File has been successfully completed by <your name> of Class
XII, Leelawati Public School for consideration in partial
fulfillment of curriculum of Central Board of Secondary
Education 2024-25.
I certify that this practical is up to my expectation and as per
the guidelines issued by the CBSE.

( Examiner) (Principal)

(Principal)
ACKNOWLEDGEMENT

I take this opportunity to express my deep sense of gratitude to all


those who have been instrumental in preparation of this project.

I feel great pleasure to express my obligation to Mrs. Sapna Gupta,


Principal of Leelawati Public School.

I am also sincerely grateful to Ms. Gunjan Tyagi, Leelawati Public


School for her encouragement and valuable guidance during the
entire period of work.

I would also thank my parents and all of my friends for their whole
hearted support and encouragement without with this project
would not have been successful.

I could not forget Internet, Textbooks which provided me with


sufficient matter for reference.

Name :

Roll No.:-
TABLE OF CONTENT
SR. Topic Page
No No.
1 Overview of Python 1
2 Overview of My SQL
3 Data Handling Practicals
4 1. Create a pandas series from a dictionary of values and an
ndarray.

5 2. Write a Pandas program to perform arithmetic operations on


two Pandas Series.

6 3. Write a Pandas program to add some data to an existing Series.

7 4. Write a Pandas program to select the rows where the percentage


greater than 70.
8 5. Write a Pandas program to select the rows the percentage is
between 70 and 90 (inclusive)

9 6. Write a Pandas program to change the percentage in a given row


by the user.
10
7. Write a Pandas program to join the two given dataframes along
rows and assign all data.

11
8. Write a Pandas program to join the two given dataframes
along columns and assign all data.

12 9. Write a Pandas program to append a list of dictionaries or series


to an existing DataFrame and display the combined data.

13 [Link] to select or filter rows from a DataFrame based on


values in columns in pandas.( Use of Relational and Logical
Operators)

14 11. Filter out rows based on different criteria such as duplicate


rows.
15 12. Filter out rows based on different criteria such as duplicate
rows.

16 13. Locate the 3 largest values in a data frame.

17 14. Subtract the mean of a row from each element of the row in a
Data Frame.
18 15. Locate the 3 largest values in a data frame.

19 16. Write a program to draw line chart depicting the prices of


the apps and download of the apps
20 17. Given the school result data, plot bar graph using function of
dataframe for subject wise analysis of performance of the students.

21 18. Write a program to create a bar chart plotting


from the columns of DataFrame.

22
19. Write a program to read a CSV file and display
contents in different format. Copy the CSV file into
other CSV file with different separator.

23
20. Write a program to create a DataFrame for student
details and create a CSV file using this DataFrame and
display contents of CSV file.

24
SQL QUERIES
25
Practical 1-Aim: Database query using SQL (Mathematical,
string, Date and time functions in SQL)

26
Practical 2-Aim: Database query using SQL (Aggregate
functions ,Group by ,order by query in SQL)
OVERVIEW OF PYTHON
Python is an open-source and cross-platform programming language. It is available for
use under Python Software Foundation License (compatible to GNU General Public
License) on all the major operating system platforms Linux, Windows and Mac OS.

To facilitate new features and to maintain that readability, the Python Enhancement
Proposal (PEP) process was developed. This process allows anyone to submit a PEP for a
new feature, library, or other addition.

The design philosophy of Python emphasizes on simplicity, readability and unambiguity.


Python is known for its batteries included approach as Python software is distributed
with a comprehensive standard library of functions and modules.

Pandas is a Python library used for working with data [Link] has functions for analyzing,
cleaning, exploring, and manipulating [Link] name "Pandas" has a reference to both
"Panel Data", and "Python Data Analysis" and was created by Wes McKinney in
[Link] allows us to analyze big data and make conclusions based on statistical
theories. Pandas can clean messy data sets, and make them readable and relevant.
Relevant data is very important in data science.

Pandas DataFrame is a two-dimensional data structure with labeled axes (rows and
columns).Pandas DataFrame is created by loading the datasets from existing storage
(which can be a SQL database, a CSV file, or an Excel file).
Pandas DataFrame can be created from lists, dictionaries, a list of dictionaries, etc.

Pandas is built on top of two core Python libraries—matplotlib for data visualization
and NumPy for mathematical operations. Pandas acts as a wrapper over these libraries,
allowing you to access many of matplotlib's and NumPy's methods with less code. For
instance, pandas' .plot() combines multiple matplotlib methods into a single method,
enabling you to plot a chart in a few lines.
OVERVIEW OF SQL

Structured Query Language, is a computer language designed for the retrieval and management of
data in relational database management systems, database schema creation and modification, and
database object access control management.

SQL has been standardized originally designed as a declarative query and data manipulation language,
variations of SQL have been created by SQL database management system (DBMS) vendors that add
procedural constructs, control-of-flow statements, user-defined data types, and various other
language extensions. With the release of the SQL: 1999 standard, many such extensions were formally
adopted as part of the SQL language via the SQL Persistent Stored Modules (SQL/PSM) portion of the
standard.

SQL has come under criticism for its lack of cross-platform portability between vendors, inappropriate
handling of missing data , complex three-valued logic system, and its complex and occasionally
ambiguous language grammar and semantics. Using SQL one can create and maintain data
manipulation objects such as table, views, sequence etc. These data manipulation objects will be
created and stroed on the server's hard disk drive, in a tablespace, to wich the user has been assigned.
Once these data manipulation objects are created, they are used extensively in commercial
applications.
DML, DCL, DDL:
Data manipulation
First, there are the standard Data Manipulation Language (DML) elements. DML is the subset of the
language used to add, update and delete data:
 INSERT is used to add rows (formally tuples) to an existing table. UPDATE is used to modify the
values of a set of existing table rows.
 MERGE is used to combine the data of multiple tables. It is something of a combination of the
INSERT and UPDATE elements. It is defined in the SQL:2003 standard; prior to that, some
databases provided similar functionality via different syntax, sometimes called an "upsert".
 DELETE removes zero or more existing rows from a table.

Data control
The third group of SQL keywords is the Data Control Language (DCL). DCL handles the authorization
aspects of data and permits the user to control who has access to see or manipulate data within the
database. Its two main keywords are:
 GRANT authorizes one or more users to perform an operation or a set of operations on an object.

 REVOKE removes or restricts the capability of a user to perform an operation or a set of


operations.
Example: GRANT SELECT, UPDATE ON my_table TO some_user, another_user
Data definition
The second group of keywords is the Data Definition Language (DDL). DDL allows the user to define
new tables and associated elements. Most commercial SQL databases have proprietary extensions in
their DDL, which allow control over nonstandard features of the database system. The most basic
items of DDL are the CREATE, ALTER, RENAME, TRUNCATE and DROP statements:
 CREATE causes an object (a table, for example) to be created within the database.
 DROP causes an existing object within the database to be deleted, usually irretrievably.
 TRUNCATE deletes all data from a table (non-standard, but common SQL statement).
 ALTER statement permits the user to modify an existing object in various ways -- for example,
adding a column to an existing table.

Example:
CREATE TABLE my_table ( My_field1 INT,
My_field2 VARCHAR (50),
My_field3 DATE NOT NULL, PRIMARY KEY
(my_field1, my_field2) );

In addition to the creation of data manipulation objects, the actual manipulation of data within these
objects is done using SQL. The SQL sentences that are used to create these objects are called DDL's or
Data Defination Language.
The SQL sentences used to manipulate data within these objects are called DML's or Data
Manipulation Language. The SQL sentences, which are used to control the behavior of these objects,
are called DCL's or Data Control Language.
PROGRAMS
1. Create a pandas series from a dictionary of values and an ndarray.

import pandas as pd
import numpy as np
s=[Link]([Link]([1,3,4,7,8,8,9]))
print(s)

# create a dictionary
dictionary = {'X' : 10, 'Y' : 20, 'Z' : 30} # create a series
series = [Link](dictionary)
print(series)

2. Write a Pandas program to perform arithmetic operations on two Pandas Series.

import pandas as pd
ds1 = [Link]([3, 6, 9, 12, 15])
ds2 = [Link]([2, 4, 6, 8, 10])
ds = ds1 + ds2
print("Add two Series:")
print(ds)
print("Subtract two Series:")
ds = ds1 - ds2
print(ds)
print("Multiply two Series:")
ds = ds1 * ds2
print(ds)
print("Divide Series1 by Series2:")
ds = ds1 / ds2
print(ds)

[Link] a Pandas program to add some data to an existing Series.

import pandas as pd
s = [Link](['S101', 'Amjad', '[Link].', 'XII – A1', '450'])
print("Original Data Series:")
print(s)
print("\nData Series after adding some data:")
new_s = [Link]([Link](['90.0', 'PASS']))
print(new_s)
4. Write a Pandas program to select the rows where the percentage greater than 70.

import pandas as pd
import numpy as np
exam_data = {'name': ['Aman', 'Kamal', 'Amjad', 'Rohan', 'Amit', 'Sumit', 'Matthew', 'Kartik',
'Kavita', 'Pooja'],
'perc': [79.5, 29, 90.5, [Link], 32, 65, 56, [Link], 29, 89],
'qualify': ['yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no', 'no', 'ye s']}
labels = ['A', 'B', 'C', 'B', 'E', 'F', 'G', 'H', 'I', 'J']
df = [Link](exam_data , index=labels)
print("Number of student whoes percentage more than 70:")
print(df[df['perc'] > 70])
5. Write a Pandas program to select the rows the percentage is between 70 and 90 (inclusive)

import pandas as pd
import numpy as np
exam_data = {'name': ['Aman', 'Kamal', 'Amjad', 'Rohan', 'Amit', 'Sumit', 'Matthew', 'Kartik',
'Kavita', 'Pooja'],
'perc': [79.5, 29, 90.5, [Link], 32, 65, 56, [Link], 29, 89],
'qualify': ['yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no', 'no', 'yes']}
labels = ['A', 'B', 'C', 'B', 'E', 'F', 'G', 'H', 'I', 'J']
df = [Link](exam_data , index=labels)
print("Number of student whoes percentage more than 70:")
print(df[df['perc'].between(70,90)])

6. Write a Pandas program to change the percentage in a given row by the user.

import pandas as pd
import numpy as np
exam_dic = {'name': ['Aman', 'Kamal', 'Amjad', 'Rohan', 'Amit', 'Sumit', 'Matthew', 'Kartik',
'Kavita', 'Pooja'],
'perc': [79.5, 29, 90.5, [Link], 32, 65, 56, [Link], 29, 89],
'qualify': ['yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no', 'no', 'yes']}
labels = ['A', 'B', 'C', 'B', 'E', 'F', 'G', 'H', 'I', 'J']
df = [Link](exam_dic , index=labels)
print("\nOriginal data frame:")
print(df)
ch = input("Enter the index of row : ")
per = float(input("Enter percentage to be changed: "))
print('\nChange the percentage in row '+ch+ ' to',per)
[Link][ch, 'perc'] = per
print(df)

7. Write a Pandas program to join the two given dataframes along rows and assign all data.

import pandas as pd
import numpy as np
exam_dic1 = {'name': ['Aman', 'Kamal', 'Amjad', 'Rohan', 'Amit', 'Sumit', 'Matthew', 'Kartik',
'Kavita', 'Pooja'],
'perc': [79.5, 29, 90.5, [Link], 32, 65, 56, [Link], 29, 89],
'qualify': ['yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no', 'no', 'yes']}
exam_data1 = [Link](exam_dic1)
exam_dic2 = {'name': ['Parveen', 'Ahil', 'Ashaz', 'Shifin', 'Hanash'],
'perc': [89.5, 92, 90.5, 91.5, 90],
'qualify': ['yes', 'yes', 'yes', 'yes', 'yes']}
exam_data2 = [Link](exam_dic2)
print("Original DataFrames:")
print(exam_data1)
print("-------------------------------------")
print(exam_data2)
print("\nJoin the said two dataframes along rows:")
result_data = [Link]([exam_data1, exam_data2])
print(result_data)

[Link] a Pandas program to join the two given dataframes along columns and assign all data.

import pandas as pd
import numpy as np
exam_dic1 = {'name': ['Aman', 'Kamal', 'Amjad', 'Rohan', 'Amit', 'Sumit', 'Matthew', 'Kartik',
'Kavita', 'Pooja'],
'perc': [79.5, 29, 90.5, [Link], 32, 65, 56, [Link], 29, 89],
'qualify': ['yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no', 'no', 'yes']}
exam_data1 = [Link](exam_dic1)
exam_dic2 = {'name': ['Parveen', 'Ahil', 'Ashaz', 'Shifin', 'Hanash'],
'perc': [89.5, 92, 90.5, 91.5, 90],
'qualify': ['yes', 'yes', 'yes', 'yes', 'yes']}
exam_data2 = [Link](exam_dic2)
print("Original DataFrames:")
print(exam_data1)
print("-------------------------------------")
print(exam_data2)
print("\nJoin the said two dataframes along rows:")
result_data = [Link]([exam_data1, exam_data2],axis=1)
print(result_data)
9. Write a Pandas program to append a list of dictionaries or series to an existing DataFrame
and display the combined data.

import pandas as pd
import numpy as np
exam_dic1 = {'name': ['Aman', 'Kamal', 'Amjad', 'Rohan', 'Amit', 'Sumit', 'Matthew', 'Kartik',
'Kavita', 'Pooja'],
'perc': [79.5, 29, 90.5, [Link], 32, 65, 56, [Link], 29, 89],
'qualify': ['yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no', 'no', 'yes']}
exam_data1 = [Link](exam_dic1)
s = [Link](['Sukhvir', 54,'yes'], index=['name', 'perc','qualify'])

dicts = [{'name': 'Krish', 'perc': 45,'qualify':'yes'},


{'name': 'Kumar', 'perc': 67,'qualify':'yes'}]
print("Original DataFrames:")
print(exam_data1)
print("\nDictionary:")
print(s)
# Add Series
combined_data = exam_data1.append(s, ignore_index=True, sort=False)
# Add Dictionary
combined_info = combined_data.append(dicts, ignore_index=True, sort=False)
print("\nCombined Data:")
# Print Combined Data/info
print(combined_info)

[Link] to select or filter rows from a DataFrame based on values in columns in


pandas.( Use of Relational and Logical Operators)

import pandas as pd
import numpy as np

exam_dic1 = {'name': ['Aman', 'Kamal', 'Amjad', 'Rohan', 'Amit', 'Sumit', 'Matthew', 'Kartik',
'Kavita', 'Pooja'],
'perc': [79.5, 29, 90.5, [Link], 32, 65, 56, [Link], 29, 89],
'qualify': ['yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no', 'no', 'yes']}
exam_data1 = [Link](exam_dic1)
print("Original DataFrames:")
print(exam_data1)
print("\nUse == operator\n")
print(exam_data1.loc[exam_data1['name'] == 'Rohan'])

print("\nUse < operator\n")


print(exam_data1.loc[exam_data1
['perc'] < 40])
print("\n Use != operator\n")
print(exam_data1.loc[exam_data1['qualify'] != 'no'])
print("\n Multiple Conditions\n")
print(exam_data1.loc[(exam_data1['qualify'] != 'yes') & (exam_data1['perc'] <40)])

[Link] out rows based on different criteria such as duplicate rows .

import pandas as pd
data={'Name':['Aman','Rohit','Deepika','Aman','Deepika','Sohit','Geeta'],
'Sales':[8500,4500,9200,8500,9200,9600,8400]}
sales=[Link](data)
# Find duplicate rows
duplicated = sales[[Link](keep=False)]
print("duplicate Row:\n",duplicated)
[Link] the sum of each column, or find the column with the lowest mean.

import pandas as pd
Pass_Perc ={'Phy': {'2017':95.4,'2018':96.4,'2019':99.2,'2020':97.4},
'Che': {'2017':96.5,'2018':97.4,'2019':100,'2020':99.2},
'Maths': {'2017':90.2,'2018':92.6,'2019':97.4,'2020':98.0},
'Eng': {'2017':99.2,'2018':100,'2019':100,'2020':100},
'IP': {'2017':95.6,'2018':100,'2019':100,'2020':100}}
df=[Link](Pass_Perc)
print(df)
print()
print('Column wise sum in datframe is :')
print([Link](axis=0))
# Print mean vaLue of each coLumn
print()
print('Column wise mean value are:')
print([Link](axis=0).round(1))
# Returns CoLumn with minimum mean vaLue

[Link] the 3 largest values in a data frame.

import pandas as pd
data={'Name':['Aman','Rohit','Deepika','Kamal','Deva','Ramesh','Adnan'],
'Sales':[8500,4500,9300,8600,9200,9600,8400]}
sales=[Link](data)
# Find 3 Largest Value for MarksinlP Column
print([Link](3,['Sales']))

14. Subtract the mean of a row from each element of the row in a Data Frame.

import pandas as pd
Pass_Perc ={'Phy': {'2017':95.4,'2018':96.4,'2019':99.2,'2020':97.4},
'Che': {'2017':96.5,'2018':97.4,'2019':100,'2020':99.2},
'Maths': {'2017':90.2,'2018':92.6,'2019':97.4,'2020':98.0},
'Eng': {'2017':99.2,'2018':100,'2019':100,'2020':100},
'IP': {'2017':95.6,'2018':100,'2019':100,'2020':100}}
df=[Link](Pass_Perc)
print(df)
print()
print('Mean of each row is:')
print([Link](axis=1))
print()
print('Datafranie after Subtracting mean value of\
each row from each element of that Row is:')
print([Link]([Link](axis=1), axis=0))
15. Replace all negative values in a data frame with a 0.

import pandas as pd
data = {'sales1':[10,20,-4,5,-1,15],
'sales2':[20,15,10,-1,12,-2]}
df = [Link](data)
print("Data Frame")
print(df)
print('Display DataFrame after replacing every negative value with 0')
df[df<0]=0
print(df)
16. Write a program to draw line chart depicting the prices of the apps and download
of the apps.
Solution:

Output:
17. Given the school result data, plot bar graph using function of dataframe for subject wise analysis
of performance of the students.
Solution:

Output:
18. Write a program to create a bar chart plotting from the columns of
DataFrame.
Solution:

Output:
19. Write a program to read a CSV file and display contents in different format.
Copy the CSV file into other CSV file with different separator.
Solution:

First create a CSV file [Link]


Output :-
[Link] a program to create a DataFrame for student details and
create a CSV file using this DataFrame and display contents of CSV file.
Solution:
Output:

Contents of [Link] file


1) Open with excel 2) Open with Notepad
SQL QUERIES

Practical 1-Aim: Database query using SQL (Mathematical, string, Date


and time functions in SQL)

Consider table SALESMAN with following data:


SNO SNAME SALARY BONUS DATEOFJOIN
A01 Beena Mehta 30000 45.23 2019-10-29
A02 K. L. Sahay 50000 25.34 2018-03-13
B03 Nisha Thakkar 30000 35.00 2017-03-18
B04 Leela Yadav 80000 NULL 2018-12-31
C05 Gautam Gola 20000 NULL 1989-01-23
C06 Trapti Garg 70000 12.37 1987-06-15
D07 Neena Sharma 50000 27.89 1999-03-18

1) Display Salesman name , bonus after rounding off to zero decimal places.
Select SNAME, round(BONUS,0) from SALESMAN;

2) Display name, total salary of all salesman after addition of salary and
bonus and truncate it to 1 decimal places.
Select sname, truncate((SALARY+BONUS),1) from SALESMAN;
3) Display remainder of salary and bonus of Salesman whose SNO starting
with ‘A’
Select MOD(SALARY,BONUS) from SALESMAN where SNO like ’A%’;

4) Display position of occurrence of string “ta” in salesmen name.


Select sname, instr(Sname,”ta”) from SALESMAN;

5) Display four characters from salesman name starting from second


character.
Select sname, substr(Sname,2,4) from SALESMAN;
6) Display last 5 characters of name of SALESMAN.
Select sname, right(Sname,5) from SALESMAN;

7) Display details of salesman whose name containing 10 characters.


Select * from salesman where length(sname)=10;

8) Display month name for the date of join of salesman


Select DATEOFJOIN, monthname(DATEOFJOIN) from SALESMAN;

9) Display currentdate and day of the year of current date.


Select date (now()),dayofyear(date(now())) from dual;
10) Display name of the weekday for the DATEOFJOIN of SALESMAN;
Select DATEOFJOIN,dayname(DATEOFJOIN) from SALESMAN;

11) Display SNO, name of the youngest SALESMAN.


Select sno, sname, dateofjoin from salesman where dateofjoin=(select
max(DATEOFJOIN) from SALESMAN);

12) Display name and salary of the oldest SALESMAN.


Select sname, salary, dateofjoin from salesman where dateofjoin=(select
min(dateofjoin) from salesman);
Practical 2-Aim: Database query using SQL (Aggregate functions ,Group
by ,order by query in SQL)

Consider the following table Vehicle:


V_no Type Company Price Qty
AW125 Wagon Maruti 250000 25
J00083 Jeep Mahindra 4000000 15
S9090 SUV Mistubishi 2500000 18
M0892 Mini Van Datsun 1500000 26
W9760 SUV Maruti 2500000 18
R2409 Mini Van Mahindra 350000 15

1. Display the average price of each type of vehicle having quantity more than
20.
Select Type, avg(price) from vehicle where qty>20 group by Type;

2. Count the type of vehicles manufactured by each company.


Select Company, count(distinct Type) from Vehicle group by Company;
3. Display total price of all types of vehicle.
Select Type, sum(Price* Qty) from Vehicle group by Type;

4. Display the details of the vehichle having maximum price.


Select * from vehicle where price=(select max(price) from vehicle);

5. Display total vehicles of Maruti company.


Select company,sum(qty) from vehicle
group by company
having company='Maruti';
6. Display average price of all type of vehicles.
Select type,avg(price) from vehicle group by type;

7. Display type and minimum price of each vehicle company.


Select type,company,min(price) from vehicle group by company;
8. Display minimum, maximum, total and average price of Mahindra company
vehicles.
Select company, min(price),max(price),sum(price),avg(price) from vehicle where company =
‘Mahindra’;

9. Display details of all vehicles in ascending order of their price.

Select * from vehicle order by price asc;

10. Display details of all vehicles in ascending order of type and descending order of
vehicle number.
Select * from vehicle order by type asc,v_no desc;

You might also like