Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

2020-21 XIIInfo - Pract.S.E.155

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

KENDRIYA VIDYALAYAS- CHENNAI REGION

PREBOARD EXMINATION -2019-20


CLASS : XII SUBJECT:INFORMATICS PRACTICES
ANSWER KEY
SECTION-A

1 a) Find the output of following program. 1


import numpy as np
a=np.array([30,60,70,30,10,86,45])
print(a[-2:6])

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

Ans: plt.barh(x, popularity, color='green')


1 mark for the correct answer

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:

train_set = np.array([1, 2, 3])


test_set = np.array([[0, 1, 2], [1, 2, 3]])
resulting_set --> [[1, 2, 3], [0, 1, 2], [1, 2, 3]]

How would you join the two arrays?

Ans: resulting_set = np.vstack([train_set, test_set])


2 marks for the correct output with syntax

e) Create a horizontal bar graph of following data. Add suitable labels. 2


City Population
Delhi 23456123
Mumbai 20083104
Bangalore 18456123
Hyderabad 13411093

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)

3mark : 1 mark for creating array , 2 marks for extracting


2 a) ____________ function applies the passed function on each individual data element of the 1
dataframe.

i) apply() ii) applymap() iii) pivot() iv) pivot_table()

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

c) Which function is used to generate a quartile in python? 1


Ans:
quantile()

1 mark for correct answer


d) Write python statement to delete the 3rd and 5th rows from dataframedf. 1
Ans:
df.drop([2,4])
1 mark for correct answer
e) What is the use of pipe() in python pandas? Give example. 2
Ans:
pipe() function performs the operation on the entire dataframe with the help of user defined or
library functions. Any example.

1 mark for correct definition


1 mark for correct example
f) Write python statements to create a data frame for the following data. 2
Name Age Designation
RAJIV 20 CLERK
SAMEER 35 MANAGER
KAPIL 45 ACCOUNTANT
Ans:
import pandas as pd
d={'Name':['RAJIV','SAMEER','KAPIL'],
'Age':[20,35,45],'Designation':['CLERK','MANAGER','ACCOUNTANT']}
df=pd.DataFrame(d)
print(df)

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

h) Consider the following data frame of automobile 3

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)

i) A dataframedfB is given with following data: 4

ItemnoItemName Color Price


1 Ball Pen Black 15.0
2 Pencil Blue 5.5
3 Ball Pen Green 10.5
4 Gel Pen Green 11.0
5 Notebook Red 15.5
6 Ball Pen Green 11.5
7 Highligher Blue 8.5

5
8 Gel Pen Red 12.5
9 P Marker Blue 8.6
10 Pencil Green 11.5
11 Ball Pen Green 10.5

Answer the following questions


(a) Display Color and corresponding item name.
(b) Find the maximum price of each ItemName.
(c) Find the minimum price of each ItemName.
(d) Count the number of items in each ItemName category.

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

3 a) What is the simplest model of software development paradigm? 1


(i) Spiral model
(ii) Big Bang model
(iii) V-model
(iv) Waterfall model
b) RAD Software process model stands for _________________ 1
Rapid Application Development
c) Scrum event is divided into how many parts? Name them 1
Scrum event has four parts:
Sprint, Daily Scrum, Sprint Review, Sprint Retrospective
d) Write two advantages and disadvantages of waterfall model. 2
Advantages of waterfall model
Easy to arrange task
Clearly defined stages
Easy to manage
Well understood milestones
Disadvantages of waterfall model
Poor model for long project
Cannot fulfill changing requirement
No working software is developed till last phase
Dificult to measure the progress in phases
(1 +1 for two valid advantages and disadvantages)
OR
Drawbacks of Pair programming:
Different skill set may kill the project.
Disagreement may occur between programmers.
Absence of partners
( 2 marks for valid answer)
e) What is Agile Manifesto? 3
(i) INDIVIDUALS AND INTERACTIONS
6
(ii) WORKING SOFTWARE
(iii) CUSTOMER COLLABORATION
(iv) RESPONDING TO CHANGE
OR
Write the advantages and disadvantages of Component Based Model
Advantages
Reduce the cost & risk of software development.
Reduce the amount of software to be developed
Faster delivery of software.
Disadvantages
Requirement changes effect the software development.
Control over the system evolution is lost
f) Explain Git and its features 3
Git is a Distributed Version Control tool that supports distributed non-linear workflows by
providing data assurance for developing quality software.
Features of Git:
Free and open source: It is freely available to download and also you can modify the
source code of it.
Automatic Backup of the Whole Repository: In case of loss of repository, it can be
recovered from other workstations too.
Maintain full history of the changes: When pull operation is performed, developer gets all
the previous edit history.
Allow offline Repo access: Developer can work with its repository offline.
Efficient Algorithm: Git provides best algorithms for branching and merging and all the
operations to work smoothly.
(1 mark for explanation of git, 2 marks for any two features)
g) Alarm Management System 4

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

h) Write SQL Commands and the output for following queries . 4

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’

SELECT COUNT(*),VCODE FROM TRAVEL


GROUP BY VCODE HAVING COUNT(*)>1;
AnsCOUNT(*) VCODE
2 V01

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

5 a) Expand the following i) GPL ii)W3C 1


General Public License
World wide web Consortium
b) What is a cyber attack? 1
Cyber attack is an umbrella term used to classify different computer and network attacks or
activities like extortion, identity theft, email hacking, hardware stealing and physical security
breaching.
c) a)Copyright 1

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

f) What do understand by Internal Threats to the System? Give two examples 3


Internal Threats: Data and programs within a computer system are vulnerable to deliberate and
accidental destruction both from within an organization and from outside it. When it is floppy
disk, Which after months of the project loading without complaint. comes up with a message,
disk unreliable, then it is termed as Internal Threat to the system.
Some Internal Threats to the System are as follows.
(i) Hardware Failure:- A disk head crash for example can make the contents of a hard disk
unreadable.
(ii) Faulty Procedures:- A careless employees who makes entries into an accounts system can
cause havoc.
(iii) Natural Disasters:- Fire flood hurricanes and earthquakes can destroy a building taking
every last customer record with it.
OR
What is Plagiarism? How to avoid plagiarism?
Plagiarism is usually defined as the "wrongful appropriation" of another's words, thoughts, ideas, or
expressions and the misrepresentation that they are the representer's original work. Of course, with a
definition that broad and vague, most any sort of researched work might be considered plagiarized.
However, plagiarism is considered academic dishonesty, but is not a crime, per se.

Use quotation mark around someone else’s phrase or words


Cite the material
Get involved in the work you are expected to do. This will reduce the chances of plagiarism.
Structure and plan your writing well in advance.
Use plagiarism checkers
Write bibliography for your work
Don’t forget your online resources

11

You might also like