0% found this document useful (0 votes)
16 views6 pages

CBSE Board Practical IP Question Bank

The document provides a series of practical exercises for students in Informatics Practices, focusing on Python programming and MySQL database management. It includes tasks such as creating and manipulating Pandas Series and DataFrames, as well as SQL queries for managing student and product data. Each section contains specific programming requirements and example code to guide students in their learning process.

Uploaded by

swetdungrani160
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views6 pages

CBSE Board Practical IP Question Bank

The document provides a series of practical exercises for students in Informatics Practices, focusing on Python programming and MySQL database management. It includes tasks such as creating and manipulating Pandas Series and DataFrames, as well as SQL queries for managing student and product data. Each section contains specific programming requirements and example code to guide students in their learning process.

Uploaded by

swetdungrani160
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

The Millennium School, Surat

Academic Year 2024-25


Practical Examination Practice worksheet
Subject: Informatics Practices (065)
1. Write Python program based on Series.
(i) Write a python program to create following series.
0 5600
1 9889
2 4576
3 6700
(ii) Set index to ‘e01’,’e02’,e03’,’e04’.
(iii) Give increment of 1000 rs to employees who are having salary less than 5000.
(iv) Display employees having salary is above 6000.
(v) Set index name to Employee code.
(vi) Display employee with maximum salary.
(vii) Display last 3 employees.
Answer:
import pandas as pd
#1
s1=pd.Series(5600,9889,4576,6700)
print(s1)
#2
s1.index=[‘e01’,’e02’,’e03’,’e04’]
print(s1)
#3
s1=s1[s1<5000]+1000
#4
print(s1[s1>6000])
#5
s1.index.name=’employee code’
#6
print(s1.max())
#7
print(s1.tail(3)
2.
(i) Write a python program to generate series of 5 students’ marks.
(ii) Set index to R01,R02,R03,R04,R05.
(iii) Give increment of 5 marks to students who are having marks less than 27.
Answer:
import pandas as pd
#1
s1=pd.Series([34,23,44,55,55])
print(s1)
#2
s1.index=[‘R01’,’R02’,’R03’,’R04’,’Ro5’]
#3
print(s1[s1<27])

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

(i) Create a DataFrame using above data.


(ii) Display all states where cases are more than 3500.
(iii) Add one Column ‘Death’ having values [100,200,150,100,120].
(iv) Update record using iloc/loc at 1st position. [99,Banglore,5988,100]
(v) Add one column Recovery by calculating (cases-death).
(vi) Delete column recovery temporarily from Dataframe.
(vii) Write code to plot bar graph of state and Death.
(viii) Write a code to plot a line graph of state and death .Also save image.
Answer:
import pandas as pd
import matplotlib.pyplot as plt
df=pd.DataFrame({‘id’:[100,110,120,130],’state’:
[‘delhi’,’mumbai’,’chennai’,’surat’],’cases’:[3000,4000,5000,4500]})
print(df)
#2
print(df[df[‘cases’]>3500])
#3
df[‘death’]=[100,200,150,100,120]
#4
#can be used iloc[], this will update /overwrite details of record
df.loc[1]=[99,'Banglore',5988,100]
#5
df[‘recovery’]=df[‘cases’]-df[‘death’]
#6
print(df.drop('recovery',axis=1,inplace=false))
#7
plt.bar(df['state'],df['death'])
#8
plt.plot(df[‘state’],df[‘death’])
plt.savefig(‘image.jpg’)
5. Consider the following data and write Python program based on DataFrame.
ItemId ItemName Manufacturer Price
PC01 Personal Computer HCL India 42000
LC05 Laptop HP USA 55000
PC03 Personal Computer Dell USA 32000
PC06 Personal Computer Zenith USA 37000
LC03 Laptop Dell USA 57000
(i) Create a DataFrame using above data.
(ii) Display all Items whose price is less than 40000.
(iii) Add one Column ‘Discount’ having values [10,20,15,10,12].
(iv) Write code to plot bar graph of ItemId and Price.
import pandas as pd
import matplotlib.pyplot as plt
#1
df=pd.DataFrame({'itemid':['pc01','pc02','pc03','pc04','pc05'],'itemname':
['personalcomputer','laptop','personal computer','personal
computer','laptop'],'maufacturer':['hcl india','hp usa','dell india','zenith usa','dell
usa'],'price':[42000,52000,32000,37000,57000]})

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()

7. Consider the following table ‘Student’.


Rollno Name Gender Mark DOB Mobile_no Stream
s
1 Deep Singh M 98 1996-08-22 89888657 Commerce
7
2 Payal Goel F 82 1998-03-21 98666655 Science
5
3 Gurpreet Kaur F 25 2000-01-04 78555565 Humanity
5
4 Akshay Dureja M 90 1997-04-05 75888855 Science
5
5 Shreya Anand F 70 1999-10-08 81556556 Commerce
5
(i) Create above table in MySQL with suitable datatype and constraints.
(ii) Insert 5 records in above table as per the given data.
(iii) Display all students from ‘science’ stream.
(iv) Display Name and DOB of students born in ‘April’.
(v) Display Stream and number of students per stream.
(vi) Display all Male students in Upper case.
(vii) Add 5 marks to students whose marks are less than 27.
SHOW DATABASES;
USE DATABASE SCHOOL;
CREATE TABLE STUDENT(ROLLNO INT PRIMARY KEY,NAME VARCHAR(30), GENDER
CHAR(1),MARKS INT(3), DOB DATE, MOBILE_NO INT, STREAM VARCHAR(20));
INSERT INTO STUDENT VALUES(1,’DEEP SINGH’,’M’,98,’1996-08-
22’,898886577,’COMMERCE’);
--- DO IT FOR REST
SELECT NAME,DOB FROM STUDENT WHERE MONTH(DOB)=4;
SELECT STREAM, COUNT(*) FROM STUDENT GROUP BY STREAM;
SELECT UPPER(NAME) FROM STUDENTS WHERE GENDER=’M’;
UPDATE STUDENT SET MARKS=MARKS+5 WHERE MARKS<27;
8. Consider the following table ‘product’.
Srno ItemName Price Manufacturer
A01 Motherboard 12000 Tech Shoppe
B02 Hard disk 5000 ABC Computers
C03 Keyboard 500 Geek Techno soft
B04 Mouse 300 Hitech Tech Store
A05 Hard disk 6000 Infotech media
(i) Create above table in MySQL with suitable datatype and constraints.
(ii) Insert 5 records in above table as per the given data.
(iii) Display all ItemName and sum of price based on ItemName.
(iv) Display details of Items with ItemName as ‘Hard disk’ and manufacturer
as ‘ABC Computers’.
(v) Display Items having ‘o’ anywhere in ItemName.
(vi) Display ItemName, Price in Descending order of Price.
(vii) Subtract 100 Rs as discount for items having Price more than 10000.

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;

You might also like