Ip 2019
Ip 2019
90/C
Candidates must write the Code on the
Roll No.
title page of the answer-book.
Instructions :
• All questions are compulsory (within questions there may be choices).
• The question paper is divided into four sections — A, B, C and D.
• Section A comprises of questions 1 and 2.
(i) Question 1 comprises Data Handling-2 (Series, Numpy).
(ii) Question 2 comprises of questions from Data Handling-2 (Data
Frames and its operations).
• Section B comprises of questions from Basic Software Engineering.
• Section C comprises of questions from Data Management-2.
• Section D comprises of questions from Society, Law and Ethics-2.
.90/D 1 P.T.O.
SECTION A
Answer the following questions :
1. (a) Find the output of the following program : 1
import numpy as np
Profits=np.array([1520, 1245, 1345, 1525, 2110, 1020,
1725])
print(Profits[2:5])
(b) Fill in the blank with appropriate numpy method to change the
contents of the given 1 dimensional array Val1D into a
2 dimensional array Val2D with 3 rows and 2 columns per row : 1
import numpy as np
Val1D=np.array([15,25,35,45,55,65])
Val2D = __________________________
(c) Fill in the blank with the correct statement to plot a bar graph using
a matplotlib method, so that Company ABC can see the graphical
presentation of its Profit figures for the 2nd quarter of the financial
year 2019 (i.e. August, September, October, November). 1
import matplotlib.pyplot as mtp
Months = ['AUG', 'SEP', 'OCT', 'NOV'] #X Axis
Profits = [125, 220, 230, 175] #Y Axis
________________________________
mtp.show()
OR
A pie chart is to be drawn (using pyplot) to represent Population of
States. Fill in the blank with correct statement using a matplotlib
method to draw the pie chart with labels for the pie slices as the
names of the States and the size of each pie slice representing the
corresponding Population of the States (in crores), as per the
following table : 1
States Population
Rajasthan 6.8
Karnataka 6.1
Tamilnadu 7.2
Goa 1.5
.90/D 2
import matplotlib.pyplot as plt
States = ['Rajasthan','Karnataka','Tamilnadu','Goa']
Population = [6.8,6.1,7.2,1.5]
_____________________________
plt.show()
import numpy as np
Score1=(np.array([90,92,94,96,95])
Score2=(np.array([95,90,98,96,92])
S1=(np.where(Scorel>Score2))
S2=(np.where(Score2>Score1))
print(Score1[S1], Score2[S2])
(e) The table below shows the Marks of two students for the four unit
tests for academic session 2019-2020. Fill in the blanks to draw a
line graph with Test Names on the X axis and Marks on the Y axis. 2
Marks
Tests
Rohit Suman
Unit1 85 97
Unit2 88 99
Unit3 89 90
Unit4 87 92
.90/D 3 P.T.O.
(f) Write single line Pandas statements for each of the following.
(Assuming necessary modules have been imported) : 2
(i) Declare a Pandas series named Packets having dataset as :
[125, 92, 104, 92, 85, 116, 87, 90]
(ii) Display the median of the elements present in the dataset of
Packets using the Pandas method for it.
(g) Write Numpy single line statement for each of the following from (i)
to (iii). 3
(i) To create a 3 2 array named ARR2D with the following
values. (Assuming necessary modules have been imported as
np) :
ARR2D
10 20
30 40
50 60
.90/D 4
(ii) Topple the contents of the array ARR upside down so that its
contents become :
ARR
100 110 120
70 80 90
40 50 60
10 20 30
(iii) Display the changed content of the arry ARR in the following
format :
[[100 110 120]
[70 80 90]
[40 50 60]
[10 20 30]]
2. (a) Write the correct option from (i) to (iv) for the method used in
Pandas to calculate the correlation of values stored in a dataframe. 1
(i) cor()
(ii) correlate()
(iii) corr()
(iv) correlation()
(b) Write the correct output on execution of the following Pandas code : 1
import pandas as pd
df=pd.DataFrame([("Om",93),("Jay",91)],columns=['Name',
'Mark'])
print(df.sort_values('Name', ascending=True))
(c) Write the correct output on execution of the following Pandas code : 1
import pandas as pd
df1= pd.DataFrame(["First","Second"],columns=['Col'])
df2= pd.DataFrame(["Third","Fourth"],columns=['Col'])
df = pd.concat([df2, df1], ignore_index=True)
print(df)
.90/D 5 P.T.O.
(d) Write the correct output on execution of the following Pandas code : 1
import pandas as pd
df = pd.DataFrame({"A":[1,3,2], "B":[5,1,4], "C":[3,4,7],
"D":[4,6,5], "E":[2,5,3]})
print(df.quantile([0.5], axis = 1) )
(e) Write the correct output on execution of the following Pandas code : 2
import pandas as pd
df = pd.DataFrame({'Name': ['Raj', 'Rita', 'Priya'],
'Type': ['Teacher', 'Student', 'Student'],
'Code': ['T01', 'S101', 'S102']})
print(df.pivot('Code','Type','Name'))
(f) Write the correct output on execution of the following Pandas code : 2
import pandas as pd
df = pd.DataFrame({"A": ["P01", "P02", "P03"],
"B": ["Pen", "Pencil", "Eraser"]})
df=df.rename(columns={"A": "PID", "B": "PNAME"})
df=df.rename(index={0: 'A', 1: 'B', 2: 'C'})
print(df)
OR
Write the use of the rename(mapper=<dict-like>, axis=1)
method for a Pandas Dataframe. Can the mapper and columns
parameter be used together in a rename() method ? 2
.90/D 6
(i) To display the total number of all ITEMS in the STOCK
(ii) To display the total QUANTITY of all ITEMS in the STOCK
(iii) To display the Average QUANTITY of all ITEMS in the STOCK
OR
Consider a dataframe Travel created with the following
information. Write single line Pandas statements for (i), (ii) and (iii) :
T_Id Type Amount
0 T_01 TO 550
1 T_02 FROM 300
2 T_03 TO 280
3 T_02 FROM 250
4 T_03 FROM 410
(i) To display the maximum value of the column Amount
(ii) To display the sum of Amounts for each Type separately (i.e.
sum of TOs and sum of FROMs)
(iii) To display the mean for the column Amount 3
Sanya 95 2 yes
Krish 70 3 no
Deepak 75 2 no
Kriti 92 1 yes
.90/D 7 P.T.O.
Number of Rows : 5
Number of columns : 4
NOTE : The code must use Dataframe methods to display the Total
number of rows and Total number of columns in the dataframe.
(i) For the above created Dataframe df in Q.2(h) write single line
statements for each of the following parts (a) to (d), which use
Pandas method : 4
a. To display the 'Names' and 'Marks' columns from the
DataFrame.
b. To change the 'Marks' in the 4th row (i.e. for index 3) to 91.5
c. To display the rows where number of 'Trials' in the
examination is less than 2 and 'Marks' is greater
than 95
d. To sort the DataFrame in descending order of 'Marks'
SECTION B
OR
(g) (i) List any two properties of an actor in a Use Case Diagram. 4
(ii) Draw the diagrammatic notations to represent an Actor and a
Use Case in Use Case Diagrams.
OR
(i) List any two properties of a Use Case in a Use Case Diagram. 4
(ii) What is an Association Link in a Use Case Diagram ? Draw a
diagrammatic notation to represent an Association Link
between a Student and the act of Borrowing Books.
SECTION C
OR
Write whether the following statement is True or False for the
POST method in Django : 1
‘‘POST requests should always be used for sensitive data’’
(c) Which of the following are correct aggregate functions in SQL : 1
(i) AVERAGE()
(ii) MAX()
(iii) COUNT()
(iv) TOTAL()
.90/D 9 P.T.O.
(d) Which of the following are not the correct names of Python files
created by django-admin inside the folder
"MyProject/MyProject" when we start a DJango project with a
command 1
"django-admin startproject MyProject"
(i) urls.py
(ii) admin.py
(iii) MyProject.py
(iv) Settings.py
C3 JASPREET
(ii) Identify the primary key and candidate keys from the table
TRANSACTIONS.
.90/D 10
(h) Write SQL queries for (i) to (iii) and the outputs for (iv) and (v),
which are based on the following table PARTICIPANTS 4
Table : PARTICIPANTS
PNO EVENT SNAME CLASS DOB
P1 DEBATE SANYAM 12 2001-12-25
P2 DEBATE SHRUTI 10 2003-11-10
P3 DEBATE MEHER 12 2001-11-10
P4 QUIZ SAKSHI 11 2002-10-12
P5 QUIZ RITESH 12 2001-10-12
P6 QUIZ RAHUL 10 2003-10-12
P7 CROSSWORD AMEER 11 2002-05-09
P8 CROSSWORD MINAKSHI 12 2001-05-09
OR
Write Python code for the following : 4
(a) To create a MySQL connection named db for localhost, with
username = "teacher" and password = "myclass"
(b) To create a database cursor named as dbcrsr.
(c) To open a database named "CLASS" using the above declared
database cursor dbcrsr.
(d) To add a new record into the table "STUDENT" in the above
connected database, "CLASS" with details for the attributes
(SNo, SName, Marks) as ("S102", "Tanya", 92.5)
.90/D 11 P.T.O.
SECTION D
5. (a) A software company purchases new computers every year and
discards the old ones into the local dumping yard. Write the name of
the most appropriate category of waste that the organisation is
creating every year, out of the following options : 1
(i) Business Waste
(ii) Commercial Waste
(iii) Solid Waste
(iv) E-Waste
OR
Write any three features of smart mobs. 3
.90/D 12