0% found this document useful (0 votes)
16 views

Practice Ques ip pract

The document consists of multiple sets of questions related to Python programming and SQL queries. It includes tasks such as creating dataframes, manipulating data, plotting charts, and performing SQL operations on given tables. Each set contains specific questions with requirements for data handling and analysis.

Uploaded by

lalbhalu662
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)
16 views

Practice Ques ip pract

The document consists of multiple sets of questions related to Python programming and SQL queries. It includes tasks such as creating dataframes, manipulating data, plotting charts, and performing SQL operations on given tables. Each set contains specific questions with requirements for data handling and analysis.

Uploaded by

lalbhalu662
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
You are on page 1/ 6

SET 1

Q – 1 Write Python code for the following:


SNO Batsman Innings Runs SR

1 Virat Kohli 11 765 90.32

2 Rohit Sharma 11 597 125.95

3 Quinton de Kock 10 594 107.03

4 Rachin Ravindra 10 578 106.45

5 Daryl Mitchell 8 418 111.07


Questions:
a) Create a dataframe ‘Cric23’ using dictionary. [2]
b) Display the Batsman name along with runs scored. [1]
c) Add one more column ‘Average’ which contains the value as division of runs and innings. Add this
column before SR column and after Runs column. [1]
d) Change the data for Daryl Mitchell – Innings – 9 , Runs – 552. [1]
e) Convert the dataframe as ’TOP5.CSV’. [1]
f) Using a dataframe ‘Cric23’ ,plot a labelled bar chart to compare the runs for all batsmen with x axis
having Batter name and customize the chart appropriately with labels and legends. [2]
Q – 2 Consider the following Table ‘Garment’ with the records given in it. Write SQL queries for the following:
Gcode Gname Qty Price Company

G1001 Suiting 10 5000 Raymond

G1002 Shirting 15 2200 Vardhman

G1003 Jeans Pant 10 1500 Ruf n Tuf

G1004 Krutas 50 4800 Fabindia

G1005 Choli 30 18000 Arika

G1006 Formal Pant 50 5500 Raymond


Queries:
a) Create above table garment [1]
b) Count the unique company from garment. [1]
c) Display maximum price of garment manufactured by raymond. [1]
d) Display the average price of Pant. [1]
e) Display the garment number, garment name and company in the descending order of their price. [1]
f) Find the difference between maximum price and minimum price from the table. [1]
g) Display garment in upper case letters and ‘discounted price’ which is price minus 5 % of price for
price in between 2100 to 10000. [1]
SET 2
Q:1 Write Python code for the following questions:

ID Team Win Lost No Result Tie Total

001 Australia 78 25 1 1 105

002 India 63 30 1 1 95

003 West Indies 43 35 0 2 80

004 England 52 39 1 1 93
a) Create a dataframe named CWC. [2]
b) Display the team having more than 50 wins. [1]
c) Add a new row values as(005, New Zealand, 59, 38, 1, 1, 99) [1]
d) Add new column ‘Title Won’ with data (6,2,2,1,0) [1]
e) Display Total no. of rows in dataframe. [1]
f) Draw a bar chart to visual performances of wins of teams. (Add labels, legend, title) [2]

Q:2 Consider the following Table ‘Patient’ with the records given in it.
Pno Pname Docno Date_adm Charges

P001 Vima Jani D201 2011-10-11 20000.00

P002 Isha Roma D506 2011-12-12 50000.00

P003 Vina Verma D201 2011-09-03 15000.00

P004 Rita Sharma D506 2011-08-05 18000.00

P005 Shiv Roy D210 2011-08-05 20000.00


a) Create the above given table with appropriate data type and constraints. [1]
b) Count the number of patients belongs to doctor no D201. [1]
c) Display name of patient paying highest charge. [1]
d) Display pno, name of patient in descending order of date of admission. [1]
e) Display the last name of patients from pname with date of admission. [1]
f) Display the patients details with charges converted to whole number. [1]
g) Display details of the patient paying minimum charge. [1]
SET 3
Q 1 Write a program in python to create the following dataframe named “country” storing the following details:

cname City billamt Tran_date

1001 Shruti Ahmedabad 9500 2010-10-01

1002 Tushar Baroda 5300 2010-01-04

1003 Jay Surat 4550 2009-03-01

1004 Sameer Ahmedabad 4000 2009-04-01

1005 Mayank Surat 8500 2008-08-05

1006 Meena Baroda 4300 2008-08-06

1007 Dhairya Ahmedabad 3000 2009-10-10


Considering the above dataframe answer the following queries by writing appropriate command in python
i. Add a new column named discount which is 10% of their bill amount.
ii. Add a row with row index 1008 as Rohan, Bharuch, 6000, 2011-04-01.
iii. Now plot a bar chart depicting the customer name on x-axis and their corresponding bill amount on y-
axis, with appropriate Graph title, x-axis title, y-axis title, gridlines and color etc.
Q – 2 Create below table “staff” and insert all records.

Sid sname designation salary dojoin Section

1001 Sagar PGT 87000 2010-11-02 Residential

1002 Ankit Clerk 24000 2010-04-01 Office

1003 Dhwani Clerk 22000 2009-01-05 Office

1004 Jenil PRT 34000 2009-07-25 Primary

1005 Roshni PGT 73000 2008-07-17 Senior

1006 Mital TGT 41000 2008-04-08 Middle

1007 Gagan Lab Assistant 24000 2009-11-23 Office


Answer the following sql queries:
i. Display the difference of maximum and minimum salary of each section.
ii. Display the staff name, designation and date of joining who joins in the month of July and April.
iii. Display the records of staff in their descending order of salary.
iv. Show first 3 character of staff name.
v. Display the records of staff who is working since last 12 years
vi. Display power of length of staff name
SET 4
Q – 1 Write a program in python to create the following dataframe named “country” storing the following
details:

Country Population BirthRate UpdateDate

0 China 1379750000 12.00 2016-08-11

1 India 1330780000 21.76 2016-08-11

2 United States 324882000 13.21 2016-08-11

3 Indonesia 260581000 18.84 2016-01-07

4 Brazil 206918000 18.43 2016-08-11

5 Pakistan 194754000 27.62 2016-08-11


Considering the above dataframe answer the following question by writing appropriate command in python
pandas:
1. Display complete data for China and India.
2. Display Country, Population and BirthRate of Brazil and Pakistan.
3. Create a CSV File from the above data frame.
4. Now plot a bar chart depicting the Country on x-axis and their corresponding Population on y-axis,
with appropriate Graph title, x-axis title, y-axis title, gridlines an color etc.

Q – 2 Consider the table “Charity” and write SQL queries for the tasks that follow:

item_id Itemname Price Qty Pdate

1 Shoes 7500 5 2022/11/30

2 Socks 475 3 2022/08/25

3 Jeans 3500 5 2022/10/19

4 T-Shirts 1400 4 2022/11/30


i) Display the name of week day when socks purchased.
ii) Display remainder after dividing price by qty

iii) Display the discount amount by 10% in two decimal places.


iv) Display the records of items purchased in the month 11.
v) Display maximum qty purchased from the table.
vi) Display itemname, price and qty in the descending order of price
vii) Display item_id, itemname and position of s in each itemname.
SET 5
Q – 1 Write a program in python to create the following dataframe named “employee” storing
the following details:

EName Post Salary Dt_join

101 Anil Manager 65000 2018-03-02

102 Akshay Clerk 33000 2018-05-01

103 Ajay Manager 75000 2018-09-15

104 Varun Analyst 66000 2018-04-11

105 Siddharth Developer 60000 2018-10-12

106 Rajesh Clerk 35000 2018-06-12


Considering the above dataframe answer the following queries by writing appropriate command in python
i. Display Name, Post and Salary for all employees earning more than 60000 .
ii. Add a new row of your choice data.
iii. Transfer these data from dataframe to csv named employees.csv.
iv. Now plot a multi-line chart depicting the Employee Name on x-axis and their corresponding Salary on y-
axis, with appropriate Graph title, x-axis title, y-axis title, legends and color etc.
Q – 2 Create the table “employee” and write sql queries for the following:
EName Post Salary Dt_join

101 Anil Manager 65000 2018-03-02

102 Akshay Clerk 33000 2018-05-01

103 Ajay Manager 75000 2018-09-15

104 Varun Analyst 66000 2018-04-11

105 Siddharth Developer 60000 2018-10-12

106 Rajesh Clerk 35000 2018-06-12


Write queries for the following:
a) Count and display employees post wise.
b) Display 3 characters from 2nd place from the column ename.
c) Display last 2 characters of post column.
d) Display ename in lower letters
e) Display most senior employee
Write output of the following:
a) Select max(dt_join) from employee;
b) Select instr(ename,’a’) from employee
c) Select power(length(post),2) from employee;
d) Select left(ename,4) from employee;
SET 6

Q – 1 Write a Python code for following questions:

medicineID Medicinename Price Manufacturer

0 5147 Paracetamol 15 Dwarkesh Pharma

1 5274 D-Cold 20 Apollo Pharmacy

2 4296 Vicks VapoRub 45 Procter & Gamlbe

3 4175 Vicks Action 500 15 Procter & Gamble

4 4385 Soframycin 85 Sanofi


a) create above Data Frame “ved_medicines”
b) Display medicines and its price.
c) Display last 4 medicines
d) Display records of medicines whose price is more 20
e) Draw a bar chart which represent medicine name on x-axis and its price on y-axis.

MySQL
Observe the above medicine table and write queries for following:
a) Display the unique manufacturer from medicine
b) Display manufacturer and total price for each manufacturer
c) Display manufacturer and price in the ascending order of price
d) Display first 4 characters of medicinename which medicine id contains 5 as last digit
e) Display all medicine names in Capital letter
Write output of the following queries:
a) Select length(right(medicinename,4)) from medicine;
b) Select instr(price,5) from medicine;
c) Select round(medicineID/2,-1) from medicine;
d) Select mid(medicinename,2,4) from medicine

You might also like