0% found this document useful (0 votes)
125 views5 pages

Class XII IP Summer Assignment

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)
125 views5 pages

Class XII IP Summer Assignment

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/ 5

Summer Assignment Class : XII Subject : Informatics Practices (065)

Q1. Create following Dataframe Hospital from a 2D dictionary having value as lists:

Q2. Create following Dataframe Sales from a 2D dictionary having values as dictionary objects:

Q3. Create following Dataframe topdf from a 2D list having dictionaries as its elements.

Q4. Write a program to create following Dataframe from a 2D list.

Q5. Write a program to create a Dataframe from a 2D array as shown below:

Q6. Write a Python code to create a DataFrame ‘temp’ by using Series method:

Q7. Create following DataFrame df using following data:

(a) Add a column called E with the following data: [14,220].


(b) Add a new record with appropriate values.
(c) Remove the column A, C.
(d) Remove first and second rows from DataFrame.

Q8. Create following Dataframe df1 :

Page 1 of 5
1) Display all the product details of record no 102,104 and 106.
2) Display product and company details of 101 and 104 records of DataFrame df1
3) Display first record and third record of DataFrame df1.
4) Display quantity and company details of all records of DataFrame df1.
5) Change the salary of record no.104 to 50000.
6) Display the details of record no 104
7) Change the company name to acer and quantity to 400 of record no 101 and 102.
8) Add new record ["mic","dell",100,450] into DataFrame df1.

Q9. Create following DataFrame batsman.

Do following operation
1) Add score1 and score2 and assign it to column total
2) Display lowest score of score1.
3) Display highest score of score2
4) change index to player1,player2, player3,player4
5) Display all the details of DataFrame whose score1 <75
6) Display only name of DataFrame whose score1 <75
7) Display name and score1 of DataFrame whose score1 <75
8) Display DataFrame in descending order of score2
9) Change the column name to batsmanno,bname, s1 ,s2 and sum of DataFrame
10)Add 5 score to those who have more than 75 score2

Q10. Write the code in pandas to create the following DataFrames:

Write the commands to do the following operations on the


DataFrames given above:
1.To add DataFrames df1 and df2.
2.To add 10 values into df1 DataFrame
3.To add 5 values into mark1 columns of DataFrame
4.To add DataFrame d1 into d2
Page 2 of 5
11. Write a program to create a series to print scalar value “5” four times.
12 Write a program to create a series object F1 using a dictionary that stores the number of
furniture in each lab of your school.
Note: Assume four furniture names are Table, Sofa, Chair and stool having 40, 2,45,26 items
respectively and pandas library has been imported as pd.
13. Write a program to create a series object using a dictionary that stores the number of
students in each house of CLASS 12D of your school.
Note: Assume four house names are Beas, Chenab, Ravi and Satluj having 18, 2, 20, 18 students
respectively and pandas library has been imported as pd.
14. Write the output of the given command:
import pandas as pd
s=pd.Series([1,2,3,4,5,6],index=['A','B','C','D','E','F'])
print(s[s%2==0])
15. Consider the following series named animal

1Write the output of the command: print(animal[::-3])


16. Give the output:
import pandas as pd
name=[‘Raj’,’Ankur’,’Harsh’]
p=pd.Series(name,index=[2,5,6])
print(p)
p1=p.reindex([2,5])
print (p1)
17. How many elements will be there in the series named “S1”?
>>> S1 = pd.Series(range(5,10))
>>> print(S1)
18. Consider the given DataFrame ‘Stock’:
Name Price
0 Nancy Drew 150
1 Hardy boys 180
2 Diary of a wimpy kid 225
3 Harry Potter 500
Write suitable Python statements for the following:
i. Add a column called Special_Price with the following
data: [135,150,200,440].
ii. Add a new book named ‘The Secret' having price 800.
iii. Remove the column Price.
iv.Remove first and third rows from DataFrame
19. Consider the following dataframe ndf as shown below:
(A) Write statements to do the following:
(a) Extract column col3
(b) Extract row t3
Page 3 of 5
(c) Extract row t2’s column col2’s value
(d) Extract row t4’s columns col2, col3, and Res
(e) Delete rows t2 and t3
(f) Delete columns col2 and Res

(B) What will be the output produced by the following statements?


(a) print(df.at[‘t3’, ‘Res’], df.at[‘t1’, ‘col3’])
(b) print(df.iat[3,2], df.iat[2,3])
(c) print(df.loc[‘t2’ : , : ])
(d) print(df.loc[ : , ‘col3’ : ] )
(e) print(print(df.loc[‘t2’ : ‘t3’, ‘col3’ : ] )
(f) print(df.iloc[ :2, 2:] )
(g) print(df.iloc[2: , :3] )
(h) print(df.iloc[1:3, 2:3])
20. What will be the output of the following code:
import pandas as pd
d = {‘one’ : pd.Series([1., 2., 3.], index = [‘a’, ‘b’, ‘c’]),
‘two’ : pd.Series([1., 2., 3., 4.], index = [‘a’, ‘b’ , ‘c’, ‘d’ ]) }
df . pd.DataFrame(d)
df1 = pd.DataFrame(d, index = [‘d’, ‘b’, ‘a’])
df2= pd.DataFrame(d, index = [‘d’, ‘a’], columns = [‘two’, ‘three’])
print(df)
print(df1)
Q21. How do you create a simple line plot using Matplotlib in Python? Include an example where you
plot the function 𝑦=𝑥2 for 𝑥 ranging from -10 to 10.
Q22. Explain how to customize the appearance of a plot in Matplotlib. Specifically, describe how to
change the title, labels, and line style of a plot. Provide an example where you plot a sine wave with
customized title, x-axis label, y-axis label, and a dashed line style.
Q23. Consider the following graph. Write the Python code to plot it. Also add the Title and Label for X
and Y axis. Use the following data to draw the graph.

Page 4 of 5
Q24. Write a Python code to draw the following bar graph representing the average marks secured by
each student in Term-2 Exam. Add the Title and Label for X-axis and Y-axis. Use the following
data to draw the graph :

Q25.

Page 5 of 5

You might also like