Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Ip Practical 2024 2025

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

Python Programming

8. Create a series that stores the area of some states in km2. Write code to find out the areas
that are more than 50000 km2. Also write program to sort the values of this series in descending
order of its indexes and store it into series object S3.
9. Write a code to create the dataframe from list of series which contains names, subjects
and mark. The program should display the complete dataframe and also add new column and
new row in a dataframe.
10. Create a dataframe mdf as shown below. Answer questions (a) to (d):
C1 C2 C3
0 13 23 37
1 19 20 21
2 11 12 13
3 13 14 15

a) Write code to create a new dataframe n1 that stores the values of dataframe mdf
b) Write code to add a column C4 in the dataframe n1 which stores the difference of
column C3 with column C2 from the dataframe n1.
c) Write code to drop the column C4 from the dataframe n1. The dataframe shouldbe
modified after this ststemnet.
d) Write code to drop the index 2 from the dataframe n1. The dataframe should be
modified after this ststemnet.
11. Create dataframe that will store name, age and weight of three persons. Print the
dataframe and also find out its transpose.

12. Create the following dataframe sales containing year wise sales figures for five sales
person in INR. Use the years as column labels and sales person names as row labels.

2014 2015 2016 2017


Madhu 100.5 12000 20000 50000
Kusum 150.8 18000 50000 60000
Kinshuk 200.9 22000 70000 70000
Ankit 30000 30000 100000 80000
Shruti 40000 45000 125000 90000

Use the dataframe created above to do the following:


a) Display the row labels of sales.
b) Display the column labels of sales.
c) Display the datatype of each column of sales.
d) Display the dimensions, shape, size and values of sales.
e) Display the last two rows of sales.
f) Display the first two columns of sales.
13.

14.

15. Consider the data given below :

App Name Price


Angry bird 75
Teen Titan 120
Marvel Comics 190
Color me 245
FUN Run 550
Write a program in python to create a dataframe using the above data and
then create a line chart depicting the price of the apps. Give appropriate
xlabel and ylabel.
16. The following table is the comparison of marks between 1 st ,
2nd and 3rd position of different streams in a School . Now
analyze the data and write a program to plot that data into a bar
chart with title and legend.

Stream % of marks of % of marks of % of marks of


1st 2nd 3rd

Science 95 89 77

Arts 97 92 77

Commerce 93 90 75

17. First 10 terms of a Fibonacci series are stored in a list namely


fib:

0,1,1,2,3,5,8,13,21,34

Write a program to plot Fibonacci series andtheir square roots with


two separate lines on the same plot. The Fibonacci series should be
plotted as a cyne line with ‘o’ markers having size as 5 and edge color
as red. The square root series should be plotted as black line with ‘+’
markers having size as 7 and edge color as red.
18. Plot a bar chart to depict the popularity of various
programming languages.
19. Write a python program to plot a line chart to depict a
comparison of population between india and Pakistan in
different years such as 1980,1990,2000,2010 and 2020.
20. Weight measurements for 16 small orders of French fries(in
grams) are given beow:

78,72,69,81,63,67,65,75,79,74,71,83,71,79,80,69

a. Create a histogram from the above data

b. Create a horizontal histogram from the above data.

c. Create a cumulative histogram from the above data.


21. Given below are sugar levels for men and women in a city.Write a
python program to compare the sugar levels amongst them
through a histogram.

Men:[113,85,90,150,149,88,93,115,135,80,77,82,119]

Wome :[67,98,89,120,133,150,84,69,89,79,120,112,100]

22. 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)

y=mu+30*numpy.random.randn(10000)

Write a program to plot this data on a cumulative bar-stacked


horizontal histogram with both x and y.

23.

24. Create a CSV file Employee.csv that stores the data like
empname, empid, salary, designation of employees in any location
of your computer. Write a python program to create dataframe
from it but dataframe should not use file’s column header rather
should use own column numbers as 0, 1, 2 and so on. Use empid
column as index labels

25. Consider the dataframe df as shown below:

Name Product Target Sales


ZoneA Purv oven 56000.0 58000.0
Zone B Paschim AC 70000.0 68000.0

Zone C Kendriya AC 75000.0 78000.0

Zone D Dakshin Oven NaN 61000.0

Zone E Uttar TV NaN NaN

Create a dataframe in python with above data. Now write the code to
store the data of df dataframe in a CSV file namely ‘product.csv’, with
NaN values sored as NULL and separator as ‘|’ .
SQL TABLES
1. Consider the table Doctor given below, write command in SQL for (1) to (4) and output for
(5) to (8).
Table : DOCTOR

ID Name Dept Gender Experience ConstFee


201 R.K. Nath ENT M 12 300
457 Mahavir Singh SKIN M 500
365 M. Asthana MEDICINE F 9 250
221 V. S. Nag ENT M 3 150
122 S. P. Sinha NEPHRO F 200
110 J. P. Pandey CARDIOLOGY M 9 500

(1) To display name of all doctors who are in Medicine having more than 10 years of
experience.
(2) To display the different departments.
(3) To display minimum consultation fee of female doctors
(4) To display name and department of male doctors who has no experience.
(5) SELECT AVG(ConstFee) FROM Doctor WHERE NOT Gender=’F’;
(6) SELECT Count(Experience) FROM Doctor;
(7) SELECT Name, Experience FROM Doctor WHERE id BETWEEN 100 AND 200;
(8) SELECT SUM(ConstFee),MAX( Experience) FROM Doctor;
2. Consider the following tables PRODUCT and answer (a) and (b) part of this
question
Table :PRODUCT

PCODE PNAME COMPANY PRICE STOCK MANUFACTUREWARRANTY


P001 TV BPL 10000 200 12-JAN-2008 3
P002 TV SONY 12000 150 23-MAR-2007 4
P003 PC LENOVO 39000 100 09-APR-2008 2
P004 PC COMPAQ 38000 120 20-JUN-2009 2
P005 HANDYCAM SONY 18000 250 23-MAR-2007 3
(a) Write MySQL commands for following Statements
i. To show details of all the PC with stock more than 110.

ii. To list the company which gives warranty for more than 2 years.

iii. To find stock value of the BPL company where stock value is sum of the
products of price andstock.

iv. To show number of products from each company.

v. To count the number of PRODUCTS which are manufactured in 2009.

vi. To show the PRODUCT name which are within warranty as on date.

(b) Give the output of following MySQL statement.

(i) Select COUNT (distinct company) from PRODUCT;

(ii) Select MAX (price) from PRODUCT where WARRANTY<=3;

(iii) select AVG (price) from PRODUCT where Company=”SONY”;

(iv) Select MIN (price) from PRODUCT where stock<200;


3. Answer the following questions based on the table CLUB given below:
TABLE :CLUB

Column Name Data Type Size Constraints Description


Member_No Integer 5 Primary Key Member number
Member_Name Varchar 40 Not Null Name of the member
Address Varchar 30 Address of the
Age Integer 2 >=18 member
Type Varchar 10 Age of the member
Type of membership
Fees Double 6,2 (temp or permanent
Membership fees

(a) Write the SQL command to create the table CLUB including the constraints.

(b) Insert two tuples.

(c) Write the SQL command to display the details of all the members whose type is
“Permanent” and fees is more than Rs. 5000.

(d) Write SQL query to add a new column called Phno.

(e) Change the fees rate by 10% if the membership is of type “Temp”

(f)Write The SQL command to display all the details of all the members whose age
is grater than eighteen.

4. Study the following table and then answer the given questions:
TEACHERS

NUMBER NAME AGE DEPARTMENT DATEOFJOIN SALARY SEX

1 JUGAL 34 COMPUTER 10/01/97 12000 M


2 PRATIGYA 31 HISTORY 24/03/98 20000 F
3 SANDEEP 32 MATHS 12/12/96 30000 M
4 SANGEETA 35 HISTORY 01/07/99 40000 F
5 SATTI 42 MATHS 05/09/97 25000 M
6 SHYAM 50 HISTORY 27/06/98 30000 M
7 SHIV OM 44 COMPUTER 25/02/97 21000 M
8 SHALAKHA 33 MATHS 31/07/97 20000 F

i. To show all the information about the teacher of History department.


ii. To list the names of female teachers who are in Hindi department.
iii. To list the names of the teachers with their date of joining in ascending order.
iv. To list the details of all the teachers who’s salary is between 20000 to 35000.
v. To list Name, age, department of all teachers. This information should be sorted on
Department.
vi. To find out the average salary of all the teachers.
vii. To find out the average salary of all the departments.
viii. To find out the departments for which the total salary is more than 50000.
ix. To find out the average salary given to each sex.
x. Write command to list structure of above table.

5. Study the following table and then answer the given questions:
Table : SchoolBus

Rtno Area_covered Capacity Noofstudents Distance Transporter Charges


1 Vasant kunj 100 120 10 Shivamtravels 100000
2 Hauz Khas 80 80 10 Anand travels 85000
3 Pitampura 60 55 30 Anand travels 60000
4 Rohini 100 90 35 Anand travels 100000
5 Yamuna Vihar 50 60 20 Bhalla Co 55000
6 Krishna Nagar 70 80 30 Yadav Co 80000
7 Vasundhara 100 110 20 Yadav Co 100000
8 Paschim Vihar 40 40 20 Speed travels 55000
9 Saket 120 120 10 Speed travels 100000
10 Jank Puri 100 100 20 Kisan Tours 95000

(a) To show all information of students where capacity is more than the no of student in
order of Rtno.
(b) To show area_covered for buses covering more than 20 km., but charges less then
80000.
(c) To show transporter wise total no. of students traveling.
(d) Add a new record with following data:
(11, “ Moti bagh”,35,32,10,” kisan tours “, 35000)

(e) Give the output considering the original relation as given:


(i) Select sum (distance) from schoolbus where transporter= ‘ Yadav Co’;

(ii) Select min (noofstudents) from schoolbus;

(iii) Select avg(charges) from schoolbus where transporter= ‘Anand travels’;

(iv) Select distinct (transporter) from schoolbus;


6.

7.
8. Answer the following questions.
Table: bills Table: items

BillNo Date I_code qty I_code Name Category


1 2010-04-01 1002 2 1001 Chowmein Chinese
1 2010-04-01 3001 1 1002 Masala Dosa South Indian
2 2010-04-01 1001 3 1003 Spaghetti Italian
2 2010-04-01 1002 1
2001 Fried Rice Chinese
2 2010-04-01 2003 2
2002 Idli South Indian
3 2010-04-02 2002 1
4 2010-04-02 2002 4 2003 Lasagna Italian
4 2010-04-02 2003 2 3001 Sushi Japanese
5 2010-04-03 2003 2 3002 Vada South Indian
5 2010-04-03 3001 1
5 2010-04-03 3002 3
Based on these tables write SQL statements for the following queries:
i) Display the average rate of a South Indian item.
ii) Display the number of items in each category.
iii) Display the total qty sold for each item.
iv) Display the total quantity of each item sold but don’t display this data for items whose quantity
sold is less than 3.
v) Display the details of bill records along with name of each corresponding item.
vi) Display the details of the bill records for which the item is “Dosa”.
vii) Display the bill records for each Italian item sold.
viii) Display the total value of items sold for each bill.

9. In a database Company, there are two tables given below:


Table: Sales Table: Location

SalesmanID Name Sales LOCATIONID


LOCATIONID LOCATIONNAME
S1 ANITA 250000 102
SINGH 101 Delhi
ARORA 102 Mumbai
S2 Y.P.SINGH 1300000 101
103 Kolkata
S3 TINA 1400000 103
JASWAL 104 Chennai
S4 GURDEEP 1250000 102
SINGH
S5 SIMI FAIZAL 1450000 103

Write SQL queries for the following:


i) To create both the tables with appropriate constraints.
ii) To display salesmanID, names of salesman, LocationID with the corresponding location names.
iii) To display names of salesman, sales and corresponding location names who have achieved sales
more than 1300000.
iv) To display names of those salesman who have SINGH in their names.
v) Write SQL command to change the locationID to 104 of the SalesmanID as S3 in the table ‘Sales’.
10. In a database, there are two tables given below:
Table : Students
AdmNo Name Class Sec RNo Address phone
1271 Utkasrsh 12 C 1 C-32 Punjabi Bagh 4356154
Madam
1324 Naresh 10 A 1 31 Mohan Nagar 435654
Sharma
1325 Md. Yusuf 10 A 2 12/12 Chand Nagar 145654
1328 Sumedha 10 B 23 59 Moti Nagar 4135654
1364 Subya Akhtar 11 B 13 12 Janak puri NULL
1434 Varuna 12 B 21 69 Rohini NULL
1461 David 11 B 1 D-34 Model Town 98787665
Dsouza
2324 Satinder 12 C 1 1/2 Gulmohar park 143654
Singh
2328 Peter jones 10 A 18 21/328 Vishal Enclave 24356154
2371 Mohini 11 C 12 37 Raja Garden 6765787
Mehta

Table: Sports

AdmNo Game CoachName Grade


1324 Cricket Narendra A
1326 volleball M.P.Singh A
1271 volleball M.P.Singh B
1434 Basket Ball L.Malhotra B
1461 Cricket Narendra B
2328 Basket Ball L.Malhotra A
2371 Basket Ball L.malhotra A
1271 Basket Ball L.malhotra A
1434 Cricket Narendra A
2328 Cricket Narendra B
1364 Basket Ball L.malhotra B

Based on these tables write SQL statements for the following queries:
i) Display the lowest and highest classes from the table Students.
ii) Display the number of students in each class from the table students.
iii) Display the number of students in Class 10.
iv) Display details of students of Cricket team.
v) Display the Admission number, name, class, section and roll number of the students whose grade
in Sports table is “A”.
vi) Display the name and phone numbers of the students of class 12 who are play some game.
vii) Display the number of students with each coach.
viii) Display the names and phone numbers of the students whose grade is ‘A’ and whose coach is
‘Narendra’.

You might also like