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

Ip Questions

Uploaded by

Maisa vv
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)
36 views5 pages

Ip Questions

Uploaded by

Maisa vv
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

1) Mr.

Sharma, a game developer, has plotted a chart to estimate the distribution of two different ratings
of the various games available in the Play Store, as shown below:

He is trying to write the following statements to plot the graph. Help Mr. Sharma to fill up the blanks
with Python code to get the desired output.
import pandas as pd
_________________ # statement 1
df =______({'Games':['Subway','Surfer','Temple Run','Candy Crush','Bottle Shot','Runner Best'],
'Rating1':[15,5,6,18,20,15], 'Rating2':[25,10,28,45,32,30] } ) # statement 2
______(kind = 'bar', x = 'Games', y =_______) # statement 3 & 4
mat.xlabel('Games')
mat.ylabel('Rating')
mat.title ('Ratings of Games')
mat.show()
i. Choose the correct Python statement to import the library to plot the bar graph in statement 1.
ii. Choose the correct Python statement to create the dataframe in statement 2.
iii. Choose the correct Python statements in statements 3 and 4, respectively, to plot a bar graph from
the dataframe created.
2) You are provided with the following data on the number of students who participated in a programming
competition over the years:

Create a bar graph to visualize the growth of participants over the years. Give appropriate labels and also
save the figure obtained.
3) Consider the given DataFrames “Stock‟
Write suitable Python statements for the following:

i.Add a column called “Price” with the following data: [300,20,50,40,15]


ii. Add a new product “ruler” with a product ID as 6, 5 number of quantities, and a price of Rs 8.
iii. Rename the column “Price” as “UnitPrice”.
4) Write python code to create a Dictionary „dict‟ to store rollno, name and marks of three students. Convert
dict into DataFrame df and display the DataFrame df.
5) Write python code to create the Series EMP with the following data(using Dictionary):

Code
E1 Sanya
E2 Krish
E3 Rishav
E4 Deepak
6) Write a program to create a series object using a dictionary that stores the number of students
in each house of class 12 of your school. Note : Assume the four house names are Beas,
Chenab, Ravi, Sutlej having 18, 2, 20, 18 students respectively and Pandas has been imported
as pd.
7) What will be produced by the following python code? [Assuming that all necessary libraries and
modules are imported ]
series1 = pd.Series(np.array([31,28,31,30]), index = ["Jan", "Feb", "Mar",”Apr”])
print(series1)
8) What will be the output of the following code:
import pandas pd
A=pd.Series(data=[35,45,55,40])
print(A>45)
9) Write SQL commands for the following queries based on the relation teacher given below:

a)To show all information about the teacher of computer department


b)To list the names of female teachers who are in Maths department
c) To Display teacher's name, salary, age for male teachers only
10) What will be the output of the following code:
import pandas pd
com=pd.Series([4,5,2,9],index=[‘mouse’,’printer’,’keyboard’,’cam’])
print(com[1:3])
11) Observe the following code write answer given below:
import pandas as pd
list1=[1,2,3,4,5,6,7,8]
list2=['swimming','tt','skating','kho kho', 'bb', 'chess', 'football',"cricket"]
school=____________________ # Statement 1
print (______________) # statement 2
a) Statement 1: Write statement to create a Series school. Assign list1 as index and list2 as data
for the index.
b) Statement 2: Write a statement to print the datatype of the given series.
12) Consider the given DataFrame “Stock‟:

PID PName Qty


0 1 Pen 8
1 2 Pencil 6
2 3 Eraser 3
3 4 Color 1
4 5 Sharpener 2
Write suitable Python statements for the following:
a) Add a column called “Price” with the following data: [32,24,30,40,10]
b) Add a new product “ruler” with a product ID as 6, 5 number of quantities, and a price
of Rs 25.
c) Rename the column “Price” as “UnitPrice”.
13) Write code to create following dataframe:

Assign proper index.


14) Complete the code to perform the following:

a) To plot the bar graph in statement 1

b) To display the graph in statement 2

c) To save the graph in statement 3


import matplotlib.pyplot as plt
x = [‘Hindi’, ‘English’, ‘Science’, ‘SS’]
y=[10,20,30,40]
____________________ #statement 1
____________________ #statement 2
____________________ #statement 3
15) Write code to create dataframe from 2D ndarray and generate the following output:

16) Consider the given DataFrame ‘Stock’ :


Name Price
0 Nancy Drew 150
1 Hardy Boys 180
2 The Hobbit 450
3 Harry Potter 500
Write suitable Python statement for the following :
a)Add a column called Special_Price with following data : [135,150,400,440]

b)Add a new book named ‘The Secret’ having price 800.

c)Remove the column Special_Price.

d)Delete the 3rd and 5th rows.

17) What will be the output of following code snippet?


import pandas as pd
lst1=[11,22,33]
s1=pd.Series(lst1)
ser1=pd.Series(lst1*2)
ser2=pd.Series(s1*2)
print(“Series 1:”)
print(ser1)
print(“Series 2:”)
print(ser2)
18) Plot the following data using a line plot :
Days=[‘Mon’, ‘Tue’, ‘Wed’, ‘Thu’, ‘Fri’, ‘Sat’, ‘Sun’]
Tickets_sold=[2000, 2800, 3000, 2500, 2300, 2500,1000]
Set marker as “*”. Set x and y label as days and number of tickets sold. Set title as day wise tickets
sold. Also, give a suitable python statement to save this chart.
19) Write a python code to create the following dataframe batsman from a dictionary.

20) Write python code to draw the following bar graph representing number of students in each
class.
CLASS STRENGTH

XII

XI
DIVISION

IX

0 10 20 30 40 50 60
NUMBER OF STUDENTS

You might also like