Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Q1.

a) Write a program in python to create the following dataframe named “emp” storing the
details of employees:

ename job salary dojoin department


1001 Scott Manager 90000 2010-10-01 Accounts
1002 Tom Clerk 34000 2010-01-04 Admin
1003 Joy Clerk 32000 2009-03-01 Admin
1004 Sam Salesman 40000 2009-04-01 Sales
1005 Martin Manager 85000 2008-08-05 Sales
1006 Michel Salesman 43000 2008-08-06 Sales
1007 Francis Clerk 30000 2009-10-10 Accounts

Considering the above dataframe answer the following queries by writing appropriate command
in python pandas.

b) Add a new column named bonus (after salary column) which is 15% of their salary.
c)Display the details of Sales and Accounts department.

d) Delete a column dojoin permanently.

e) Now plot a bar chart depicting the employee name on x-axis and their corresponding Salary
(Rs.) on y-axis, with “Salary Analysis” as graph title, appropriate title for x-axis and y-axis. Also
make the color of bars “red”.

Q2. Consider the following two tables Product and Client.


PRODUCT
PID P_Name Manufacturer Price
T006 Talcom Powder LAK 40
FW06 Face Wash ABC 45
BS01 Bath Soap ABC 55
SH06 Shampoo XYZ 120
FW12 Face Wash XYZ 95
CLIENT
C_ID C_Name City PID
01 Cosmetic Shop Delhi FW05
06 Total Health Mumbai BS01
12 Live Life Delhi SH06
15 Pretty Women Delhi FW12
16 Dreams Bangalore TP01

Write SQL commands for (a) to (g).


(a) Display client name, city from the table Client and product name and price from the table
product with their matching PID.
(b) Display product name and price of Delhi clients.
(c) Display the details of the product whose product name starts with the letter ‘T’.
(d) Display maximum and minimum price for each manufacturer.
(e) Display the position of ‘t’ in client name column.
(f) Display detail of products in descending order of their price.
(g) Display the product name whose average price is 70.

Q1. a) Write a program in python to create the following dataframe named “temp” storing the
following details:

Cid City MaxTemp MinTemp Rainfall


0 C01 Delhi 40 32 24.1
1 C02 Bengaluru 31 25 36.2
2 C03 Chennai 35 27 40.8
3 C04 Mumbai 29 21 35.2
4 C05 Kolkata 39 23 41.8
5 C06 Allahabad 41 30 32.4

Considering the above dataframe answer the following queries by writing appropriate command
in python pandas.
b) Add a new column named Humidity as [54, 65,70,75,71,59].

c) Display City, MaxTemp, MinTemp of Delhi and Mumbai.

d) Change the column name MaxTemp to MxT.

e) Now plot a bar chart depicting the City Name on x-axis and their corresponding
MaxTemp on y-axis, with “Temperature Analysis” as Graph title, “City” as x-axis title and “Max
temperature” as y-axis title and bar width as 0.25.
Q2. Consider the following tables STORE and ITEM.
Table: STORE
SNo SName Area
S01 ABC Computronics GK II
S02 ALL Infotech Media CP
S03 Tech Shoppe Nehru Place
S04 Geeks Tecno Soft Nehru Place
S05 Hitech Tech Store CP

Table: ITEM
INo IName Price SNo
T01 Mother Board 12000 S01
T02 Hard Disk 5000 S01
T03 Keyboard 500 S02
T04 Mouse 300 S01
T05 Mother Board 400 S03
T06 Key Board 400 S03
T07 LCD 6000 S04
T08 LCD 5500 S05
T09 Mouse 350 S05
T10 Hard Disk 4500 S03

Write SQL commands for (a) to (g).


(a) To display IName and Price of all the Items in ascending order of their price.
(b) To display SNo and SName of Hitech Tech Store.
(c) To display Item Name, Price of all items and their respective Store Name where they are
available.
(d) To display the details of all items whose item names are starting with ‘M’ and price is
between 300 and 500.
(e) Display first 3 letters of area.
(f) To display Item name, Price and Store Name of all stores located in CP.
(g) Display Average price of each item.
Q1. a) Write a program in python to create the following dataframe named “df” storing the
following details:

TName Post Subject Salary dojoin


101 Mr.R K Sharma TGT Science 45000 2018-04-01
102 Mr. Shiv Sahai TGT Hindi 43000 2018-04-01
103 Ms. Rama PRT English 35000 2018-08-11
104 Ms. Preeti PGT IP 76000 2018-01-07
105 Ms. Nidhi PGT IP 80000 2018-08-11
106 Mr. P K Khanna TGT Science 45000 2018-01-07

Considering the above dataframe answer the following queries by writing appropriate command
in python pandas.
b) Add a Row with the following data values:
TName: Ms. Ritu Post: PRT Subject: Computer Salary: 35000 Dt_Join: 2019-01-06
c) Display Teacher Name, subject and Salary for all TGT teachers.
d) Add a new column Bonus which is 15% of their Salary.
e) Plot a line chart depicting the Teacher Name on x-axis and their corresponding
Salary on y-axis, with “Teacher wise Salary Analysis” as Graph title, “Teacher Name” as x-axis
title, “Salary” as y-axis title and make the line color “red”.

Q2. Consider the tables given below “Trainer” and” Course”.


Write SQL commands for questions (a) to (g).
(a) Display the Trainer Name, course name, City and Salary in descending order of their
Hiredate .
(b) To display the TNAME and CITY of Trainer who joined the Institute in the month of
December.
(c) To display number of Trainers from each city.
(d) To display trainer name and course name for the courses whose fees is more than 15000.
(e) Display the length of TrainerName column of Trainer table.
(f) Display details of all the trainers whose are not getting salary.
(g) Display total salary paid to the trainers who belong to city Delhi.

You might also like