Ip Practical File Class 12

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

Python Pandas:- Series

Q1:- Number of students in classes 11


and 12 in three given streams (‘Science’
’Commerce’ and ‘Humanities’) are stored
in two Series objects c11 and 12. Write
code to find total number of students in
classes 11 and 12, stream wise.

Solution :-

Output :-
Q2 :- Answer The Following :-

I ) Write A Code to create 2 Series object


using python sequence
Series 1 :- [10,20,30,40,50,60,70,80)]
Series 2 :- [22,44,56,77,88,99,101,122].
Assume that pandas is imported as alias
name pd.

Solution :-
Q3 :- Answer The Following :-
I ) Write A Code to create a Series object
using a dictionary that stores the number
of students In each section of class 12 in
your school.

II ) Write a Code to create a Series object


using two different words : “I”, ”Am”,
“Crying”, “So”, “Hard”. Assume that
pandas is imported as alias name pd.

Solution :-
Q4 :- Object 1 Population stores the
details of population in four metro cities
of india and object 2 AvgIncome stores
the total avg income reported in prv. Year.
Calculate income Per capita for each of
these metro cities.

Solution :-

Output
Q5 :- Write a code to create a Series
object that stores the contribution
amount as the values and the section
names as the indexes with datatype as
float32. The donation will be doubled.

Solution :-

Output :-
Q6 :- Consider a given Series Subject :-

English 87
Economics 54
Hindi 78
Accountancy 89
Business Studies 67

Write a program in python pandas to


create the series.

Solution :-

Output :-
Python Pandas : DataFrame

Q1 :- Create and display a Dataframe


From a 2D dictionary , Sales , Which
stores the quarter-wise sales as inner
dictionary for 4 years , as shown below:
Sales={‘yr1’:{‘Qtr’:45000,’Qtr2’:54000,’Qtr3’:23000,’Qtr4’:59000},
‘yr2’:{‘Qtr’:46000,’Qtr2’:87900,’Qtr3’:56000,’Qtr4’:81000},
‘yr3’:{‘Qtr’:15000,’Qtr2’:76300,’Qtr3’:85900,’Qtr4’:14800},
‘yr4’:{‘Qtr’:57800,’Qtr2’:91200,’Qtr3’:60900,’Qtr4’:12790}}

Solution :-
Q2 :- Write a program to create a
Dataframe from a list containing
dictionaries of the sales performance of
five zonal offices. Zone names should be
the row labels.

Solution :-

Output :-
Q3 :- Answer the following :-

I ) Write a program to create DataFrame


from a 2d list specify own index labels.

II ) Write a program to create a Dataframe


to store weight , age , and names of 3
people. Print the DataFrame and its
transpose.

Solution :-
Q4 :- Write a program to create a
DataFrame Place With Columns
Population , Hospitals And Schools and
with Index [ Delhi , Mumbai , Kolkata ,
Chennai And Banglore ]

Solution :-

Output :-
Q5 :- From the dtf5 used in the above
question, create another DataFrame and
it must not contain the column
“Population” And the row Banglore.

Solution :-

Output :-
Q6 :-- Write a program to create a
DataFrame Place With Columns
Population , Hospitals And Schools and
with Index [ Delhi , Mumbai , Kolkata ,
Chennai And Banglore ]. Transfer it and
read the same in csv file.

Solution :-
Q7 :- Consider the following DataFrame
Salesdf :-

Target Sales

Zone A 56000 58000


Zone B 87000 70000
Zone C 45000 41500
Zone D 68700 65500

I ) WAP to add a column namely Orders having values


6000,6700,6200 and 6000 respectively for the zones A,B,C,D. The
program should also add a new row for a new zone ZoneE. Add
some dummy values in this row.

Solution :- Output :-
Q8 :- Write a program to create a
DataFrame namely Aid that stores the aid
by NGOs for different states. Transfer the
data in csv file and read the same.

Solution :-
Q9 :- Create a DataFrame based on
ecommerce data and generate
descriptive statistics ( Mean , Median ,
Mode , Quartile And Variance ).

Solution :-

Output :-
Plotting Line Graph

Q1 :- Write a program to plot a line chart


to depict the changing weekly onion
prices five weeks. Give appropriate axes
labels.

Solution :-

Output :-
Q2 :- Write a program to create
DataFrame “ Df “ Having Column as week
and marks. Also plot a line graph for the
same.

Solution :-

Output :-
Plotting Bar Graph

Q1 :- Write A Program to plot a Bar chart


from the medals won by Australia. In the
same chart , plot medals won by India
too.

Solution :-

Output :-
Q2 :- Write a Program To create a
DataFrame “ Tournaments “ Having
column as [ Gold , Silver , Bronze ,
Copper]. Also plot a bar graph from the
medals won by India Only for the same.

Solution :-

Output :-
Plotting Histogram

Q1 :- Prof Awasthi is doing some research in


the field of Environment. For some plotting
purposes , he has generated some data as :-

Mu=100
Sigma=15

X=mu+sigma*numpy.random.randn(10000)

Solution :-
Q2 :- A Survey gathers height and weight of
100 participants and recorded the
participants ages as :-
Ages=[1,1,2,3,5,7,8,9,10,11,13,13,15,16,17, 18,19,20,21,21,23,24,24,24,25,25,25,26,26,
26,27,27,27,27,29,30,30,30,30,31,33,34,34, 34,35,36,36,37,37,38,38,39,40,40,41,41,42,
43,45,45,46,46,47,48,48,49,50,51,51,52,52, 53,54,55,56,57,58,60,61,63,65,66,68,70,72,
74,75,77,81,83,84,87,89,90,91]

Write a program to plot a histogram from


above data with 20 bins.

Solution :-

Output :-
MySQL – Structured Query Language

Single Table Questions

Q1 :- Write a program to create a


Database Product. Show the creation and
insertion of a values in a relation in a
proper manner.

Solution :-

Creating Table Product In Items Database:

Output
Inserting Values In A Relation Product :-

Displaying the relation with all the values :


Now we have to run the SQL statements
On This Relation.
Questions

1 :- Write a Program to display the


Average of “ UPrice “ attribute from the
relation Product.

Solution :-

Output :-

2 :- Write a program to display the


minimum price from the relation
“ Product “ .
Solution :-

Output :-

3 :- Write a program to count number of


rows from a relation “ Product “

Solution :-

Output :-
4 :- Write a program to display “ Washing
Powder “ in uppercase Letter.

Solution :-

Output :-

Q2 :- Write a program to create a


Database “ Gym “. Show the creation and
insertion of values in a relation in a
proper manner.

Solution :-
Creating table Fitness in Gym Database :-

Inserting Values in A Relation Gym :-


Displaying the relation with all the values :
Questions :-

1 :- Write a program to display the


maximum price from the relation Fitness.

Solution :-

Output :-

2 :- Write a program to display the


average of price from the relation Fitness.
3 :- Write a program to Extract the string
“lti” From the String “ Multi Gym “ From
the relation Fitness.

Solution :-

Output :-

4 :- Write a program to display the sum of


price from the relation Fitness.
Solution :-

Output :-

Q3 :- Write a program to create a


Database “ Drinks “ . Show the creation
and insertion of a values in a proper
manner.

Solution :-
Creating table Softdrink In A Drinks
Database :-

Inserting Values in a relation Soft drink :-


Displaying the relation with all the values :
Questions :-

1 :- Write a program to display the


maximum number of calories and
minimum number of price from the
relation Softdrink.

Solution :-

Output :-

2 :- Write a program to display the avg of


calories and price from the relation.
Solution :-

Output :-

3 :- Write a program to display the


remainder after dividing the two numbers
from the column Calories .

Solution :-

Output :-
4 :- Write a program to display the string “
Nature Necter “ In Lowercase letter.

Solution :-

Output :-
MYSQL – Multi Table Questions

Q1 :- Write a program to create a


database “ Airport “ . Make 2 Relations in
it and join them. Show the creation and
insertion of values in a relation in the
proper manner.

Solution :-

Creating Table Passenger And Flight In


Airport database :-

Relation Passenger :- Relation Flight:-


Inserting values in a relation Flight First :-
Inserting Values in a relation Passenger :-

Displaying the relation with all the values :


Flight Relation Passenger Relation
Questions :-

1 :- Write a query to change the fare to


6000 of the flight whose Fno is F104.

Solution :-

Output :-

2 :- Write a query to display the total


number of Male and Female Passengers.

Solution :-
3 :- Write a query to display the
Name,Corresponding Fare and F_Date of
all Passengers Who have a Flight to Start
from Delhi.

Solution :-

Output :-
Q2 :- Write a Program to create a
Database Office and Join them. Also Show
the workings in a proper manner.

Creating Table Company And Customer In


A Database Office :-
e

Inserting values In a Relation Company


First :-
Inserting Values In A Relation Customer
Now :-
Displaying the values of all the Relations :-

Company Relation Customer Relation


Questions :-

1 :- Write a query to display the name of


the companies in reverse alphabetical
order.

Solution :-

Output :-
2 :- Write a query to display The
Productname, City , Price From the
relation Company And Customer. Join
them and display those values whose
Productname is Mobile.

Solution :-

Output :-

3 :-Write a query to display the total


number of rows and city from the
relation company. Group them Also.

Solution :-
Output :-

4 :- Write a query to increase the prize by


1000 for those customer whose name
starts with S.

Solution :-
Q3 :- Write a Program to create a
database “ Showroom”. Join them and
show the creation and insertion of values
in a relation in a proper manner.

Solution :-

Creating Relation Vehicle And Travel In


Database :-

Inserting Values in a relation Vehicle First :


Inserting Values in a relation Travel Now :-
Displaying All The Values of the relations :

Vehicle Relation Travel Relation


Questions :-

1 :- Write a query To display Cno , Cname


And TravelDate from the table Travel in
descending order of Cno.

Solution :-

Output :-

2 :- Write a query to display Vcode and


the total number of rows From the
relation Travel. Group them and display
those values whose Count (*) is greater
than 1.

Solution :-

Output :-

3 :- Write a query to display Vcode ,


Cname , VehicleType From the relation
Travel And Vehicle. Join Them Using Sql
Query And Show Only Those Values
whose KM is greater than 90.

Solution :-
Output :-

4 :-Write a query to display all the details


from the table Travel for the customers,
who have travel distance more than 120
KM in ascending order of Nop.

Solution :-

Output :-

You might also like