2020-21 XIIInfo - Pract.S.E.155
2020-21 XIIInfo - Pract.S.E.155
2020-21 XIIInfo - Pract.S.E.155
Ans: [86]
1 mark for the correct output
b) x=np.array([1,2,3]) 1
y=np.array([3,2,1])
z=np.concatenate([x,y])
print(z)
Ans: [1 2 3 3 2 1]
1 mark for the correct answer
c) Mr. Shiv wants to plot a scatter chart for the given set of values of subject on x-axis and number 1
of students who opted for that subject on y-axis.
Complete the code to perform the following :
(i) To plot the scatter chart in statement 1
(ii) To display the scatter chart in statement 2
import matplotlib.pyplot as plt
x=['Hindi', 'English', ’Math’, 'Science', 'SST']
y=[10,20,30,40,50]
__________statement 1
__________statement 2
Ans: plt.scatter(x,y)
plt.show()
(1/2 mark for each correct line of the answer)
OR
MrAjay wants to plot a horizontal bar graph of the above given set of values with programming
language on x axis and its popularity on y axis with following code.
importmatplotlib.pyplotasplt
x =['Java','Python','PHP','JS','C#','C++']
popularity =[22.2,17.6,8.8,8,7.7,6.7]
_______________________ Statement 1
plt.xlabel("Popularity")
plt.ylabel("Languages")
plt.show()
Complete the code by writing statement1 to print the horizontal bar graph with colour green
1
d) Suppose you want to join train and test dataset (both are two numpy arrays train_set and 2
test_set) into a resulting array (resulting_set) to do data processing on it simultaneously. This is
as follows:
Ans:
import numpy as np
import matplotlib.pyplot as plt
Cities=[‘Delhi’,’Mumbai’,’Bangalore’,’Hyderabad’]
Population=[23456123,20083104,18456123,13411093]
plt.barh(Cities,Population)
plt. ylabel(‘Cities’)
plt.xlabel(‘Population’)
plt.show()
½ mark for lists , ½ mark for barh() function , ½ mark for labels , ½ mark for show()
f) Write a Pandas program to convert a NumPy array to a Pandas series 2
Ans:
import numpy as np
import pandas as pd
np_array = np.array([10, 20, 30, 40, 50])
print("NumPy array:")
print(np_array)
new_series = pd.Series(np_array)
print("Converted Pandas series:")
print(new_series)
2 marks for the correct code / example code snippet
g) Write a NumPy program to create a 2d array with 1 on the border and 0 inside. 3
Original array:
[[ 1. 1. 1. 1. 1.]
2
[ 1. 1. 1. 1. 1.]
[ 1. 1. 1. 1. 1.]
[ 1. 1. 1. 1. 1.]
[ 1. 1. 1. 1. 1.]]
Expected Output:
1 on the border and 0 inside in the array
[[ 1. 1. 1. 1. 1.]
[ 1. 0. 0. 0. 1.]
[ 1. 0. 0. 0. 1.]
[ 1. 0. 0. 0. 1.]
[ 1. 1. 1. 1. 1.]]
Ans:
import numpy as np
x = np.ones((5,5))
print("Original array:")
print(x)
print("1 on the border and 0 inside in the array")
x[1:-1,1:-1] = 0
print(x)
Ans: applymap()
1 mark for the correct answer
b) A dictionary smarks contains the following data: 1
Smarks={‘name’:[‘rashmi’,’harsh’,’priya’],’grade’:[‘A1’,’A2’,’B1’]}
Write a statement to create DataFrame called df. Assume that pandas has been imported as pd.
Ans:
import pandas as pd
Smarks={'name':['rashmi','harsh','priya'],'grade':['A1','A2','B1']}
df=pd.DataFrame(Smarks)
print(df)
1 mark for correct answer
OR
In pandas S is a series with the following result:
S=pd.Series([5,10,15,20,25])
The series object is automatically indexed as 0,1,2,3,4. Write a statement to assign the series as
a,b,c,d,e index explicitly.columns.
Ans:
import pandas as pd
S=pd.Series([5,10,15,20,25],index=['a','b','c','d','e'])
3
print(S)
1 mark for correct answer
½ mark for importing pandas, 1 mark for creating dictionary , ½ mark for using DataFrame function
g) A dataframe df1 is given with following data: 3
NameEnglish Accounts Economics Bst IP
Aashna 87.0 76.0 82.0 72.0 78.0
Simran 64.0 76.0 69.0 56.0 75.0
Jack 58.0 68.0 78.0 63.0 82.0
Raghu 74.0 72.0 67.0 64.0 86.0
Somya 87.0 82.0 78.0 66.0 67.0
Ronald 78.0 68.0 68.0 71.0 71.0
Write the command to given an increment of 5% to all students to DataFrame df1 using
applymap() function.
Ans:
def increase5(x):
return x + x*0.05
df1.applymap(increase5)
Or
4
Consider the data frame
dfC = pd.DataFrame({'Student Name' : ['TANVI GUPTA', 'MRIDUL KOHLI', 'DHRUV TYAGI',
'SAUMYA PANDEY', 'ALEN RUJIS', 'MANALI SOVANI', 'AAKASH IRENGBAM', 'SHIVAM
BHATIA'],'Height' : [60.0, 62.9, np.nan, 58.3, 62.5, 58.4, 63.7, 61.4], 'Weight' : [54.3, 56.8, 60.4,
58.3, np.nan, 57.4, 58.3, 55.8]}
(i) Count the number of non-null value across the column for DataFramedfC.
(ii) Find the most repeated value for a specific column ‘Weight’ of DataFramedfC.
(iii) Find the median of hieght and weight column for all students using DataFramedfC
Ans:
(i) dfC.count(axis='columns')
(ii) dfC['Weight'].mode()
(iii) dfC.loc[:, ['Height', 'Weight']].mean()
wheel- num-of-
index company body-style base cylinders price
0 bmw sedan 101.2 four 16925
1 bmw sedan 101.2 six 20970
2 honda sedan 96.5 four 12945
3 honda sedan 96.5 four 10345
4 toyota hatchback 95.7 four 5348
5 toyota hatchback 95.7 four 6338
(i) From the given data set print first and last five rows
(ii) Find the most expensive car company name
(iii) Sort all cars by price columns
Ans:
(i) df.head(5)
df.tail(5)
(ii) df = df [['company','price']][df.price==df['price'].max()]
(iii) carsDf = df.sort_values(by=['price', 'horsepower'], ascending=False)
5
8 Gel Pen Red 12.5
9 P Marker Blue 8.6
10 Pencil Green 11.5
11 Ball Pen Green 10.5
Ans:
(a) dfX = dfB(['ItemName', 'Color'])
(b) dfB.groupby('ItemName').Price.max()
(c) dfB.groupby('ItemName').Price.min()
(d) dfB.groupby('ItemName')['Color'].apply(dfB.count())
1 mark for each correct answer
SECTION- B
OR
Actors: Cellular network and User
Use cases: Place phone call, receive phone call, use scheduler, place conference call and receive
additional call
Relationship:
7
Place phone call <<extends>> Place conference call
Receive phone call <<extends>> Receive additional call
Details of Use-cases:
(i) Place Phone call-
Type- Standard use case
Linked use cases: Place conference call (extension use case)
Actors involved: Cellular network and user
Main flow:
(a) The use case is activated by user and cellular network.
(b) This use case can activate the place conference call use case.
(ii) Receive phone call-
Type- Standard use case
Linked use cases: receive additional call (extension use case)
Actors involved: Cellular network and user
Main flow:
(a) The use case is activated by user and cellular network.
(b) This use case can activate receive additional call use case.
(iii) Use scheduler-
Type- Standard use case
Linked use cases: None
Actors involved: user
Main flow: The use case is activated by user.
(iv) Place conference call-
Type- Extension use case
Actors involved: user, cellular network
Main flow: The use case is activated by Place phone call(not always).
Return to ‘ Place phone call’ main flow.
(v) Receive additional call-
Type- Extension use case
Actors involved: user, cellular network
Main flow: The use case is activated by Receive Phone call(not always).
Return to ‘Receive phone call’ main flow.
SECTION- C
4 a) Name any two files that are found in project’s application folder 1
½ mark for one valid file name
b) What is the difference between Update and Alter Commands of SQL? 1
OR
What is the difference between commit and rollback command of SQL?
½ mark for each correct difference
c) Differentiate between GET and POST methods? 1
½ mark for each proper difference
d) Find the error in the following command: 1
Select * from Employee where DOJ is 2018-04-01;
Select * from Employee where DOJ = ‘2018-04-01’;
e) What is the difference between Char and Varchar data type of SQL? 1
½ mark for each correct difference
f) What are the different keys available in SQL?Explain with example 3
1 mark for each key with proper explanation and example
g) What do you understand by degree and cardinality of a relation? If table1 having 3 rows and 5 3
columns and table2 having 2 rows and 4 columns then what will be the degree and cardinality
of the Cartesian product of table1 and table2
8
1 mark for difference , 1 mark for Degree :9, 1 mark for cardinality :6
To display CNO, CNAME, TRAVELDATE from the table TRAVEL in descending order of CNO.
AnsSELECT CNO, CNAME, TRAVELDATE FROM TRAVEL ORDER BY CNO
DESC;
To display the CNAME of all the customers from the table TRAVEL who are
traveling by vehicle with code V01 or V02.
AnsSELECT CNAME FROM TRAVEL WHERE VCODE=‘V01’ OR
VCODE=’V02’;
OR
SELECT CNAME FROM TRAVEL WHERE VCODE IN (‘V01’, ‘V02’);
Todisplay the CNO and CNAME of those customers from the table TRAVEL who travelled
between ‘2015‐12‐31’ and ‘2015‐05‐01’.
AnsSELECT CNO, CNAME from TRAVEL WHERE TRAVELDATE >=
‘2015/05/01’
AND TRAVELDATE <= ‘2015/12/31’
;
OR
SELECT CNO, CNAME from TRAVEL
WHERE TRAVELDATE BETWEEN ‘2015/05/01’
AND ‘20151231’
;
OR
SELECT CNO, CNAME from TRAVEL
WHERE TRAVELDATE <= ‘2015/12/31’
AND TRAVELDATE >= ‘2015/05/01’
;
OR
SELECT CNO, CNAME from TRAVEL
WHERE TRAVELDATE BETWEEN ‘2015/12/31’
AND ‘2015/05/01’
9
2 V02
(½ Mark for correct output)
SELECT DISTINCT VCODE FROM TRAVEL;
AnsDISTINCT VCODE
V01
V02
V03
V04
V05OR
Consider the table Employee table with the following structure:
Column name Data Type Size Constraint
Empno Char 4 Primary Key
Name Varchar 25
Dateofjoin Date
Gender Char 1
Salary Decimal 8,2
Deptcode Char 4
Write a python program to read all the rows from Employee table whose salary is between 40000 and
60000. Display the rows in a formatted manner. P-418 sahoo
1 mark for opening database connection
½ mark for creating cursor
½ mark for sql query
½ mark for fetchall()
½ mark for correct for loop
1 mark for printing in correct format
SECTION- D
d) Amit used a pen drive to copy files from his friend’s laptop to his office computer. Soon his 2
office computer started abnormal functioning. Sometimes it would restart by itself and
sometimes it would stop functioning totally. Which of the following options out of (i) to (iv),
would have caused the malfunctioning of the computer.
Justify the reason for your chosen option:
(i) Computer Worm
(ii) Computer Virus
(iii) Computer Bacteria
(iv) Trojan Horse
Ans:
(ii) Computer Virus
10
OR
(iv) Trojan Horse
Pen drive containing Computer Virus / Trojan Horse was used before the abnormal functioning
started, which might have corrupted the system files.
Computer Virus/ Trojan Horse affects the system files and start abnormal functioning in the
computer
e) 1 mark for each correct advantage of Online Campaigning? 2
11