CBSE Board Practical IP Question Bank
CBSE Board Practical IP Question Bank
3.
Write Python program based on Series.
(i) Write a python program to generate series of 4 houses and respective score.
House=[‘Agni’, ’Aakash’, ’Pruthvi’, ’Jal’]
Score=[250,150,220,180]
(ii) Display house details having score less than 200.
Answer:
#1
import pandas as pd
houses=[‘Agni’,’Askash’,’Pruthvi’,’Jal’]
score=[250,150,220,180]
s1=pd.Series(houses,score)
#2
print(s1[s1<200])
4. Consider the following data and write Python program based on DataFrame.
ID STATE CASES
100 Delhi 3000
110 Mumbai 4000
120 Chennai 5000
130 Surat 4500
print(df)
#2
print(df[df['price']<40000])
#3
df['discount']=[10,20,15,10,12]
print(df)
#4
plt.bar(df['itemid'],df['price'])
plt.show()
6. Consider the following data and write Python program based on DataFrame.
Player_id Player Team Category Runs
P01 Hardik Pandya Mumbai Indians Batsman 1000
P02 KL Rahul Kings Eleven Batsman 2400
P03 Andre Russel Kolkata Knight Riders Batsman 900
P04 Jasprit Mumbai Indians Bowler 200
Bumrah
P05 Virat Kohli RCB Batsman 3600
(i) Create a DataFrame using above data.
(ii) Display all Players whose runs are greater than 1000.
(iii) Add one Column ‘BidPrice’ having values [13,12,7,10,17].
(iv) Write code to plot bar graph of Player and Score.
(v) Give suitable title, axes label to graph. Also save graph with name’bidprice.jpg’.
#1
import pandas as pd
import matplotlib.pyplot as plt
df=pd.DataFrame(…..)
print(df)
#2
print(df[df[‘runs’]>1000])
#3
df[‘bidprice’]=[13,12,7,10,17]
print(df)
#4
plt.bar(df[‘player’],df[‘score’])
#5
plt.xlabel(“player name”)
plt.ylabel(‘score’)
plt.title(‘ipl analysis’)
plt.show()
Answer (3 onwards)
SELECT ITEMNAME, SUM(PRICE) FROM PRODUCT GROUP BY ITEMNAME;
SELECT CONCAT(ITEMNAME,’-‘,MANUFACTURER) AS ITEMDETAIL FROM
PRODUCT;
SELECT * FROM PRODUCT WHERE ITEMNAME LIKE %O%;
SELECT ITEMNAME,PRICE FROM PRODUCT ORDER BY PRICE DESC;
UPDATE PRODUCT SET PRICE=PRICE-100 WHERE PRICE>10000;