Ip pb1 QP Ms Agra Set A

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 17

SET-A

KENDRIYA VIDYALAYA SANGATHAN, AGRA REGION

PRE BOARD EXAMINAION 2019-20

CLASS XII INFORMATICS PRACTICES(065)

Time allowed: 3 hours Max. Marks: 70

MARKING SCHEME
Section A
Answer the following questions :
1 a) Find the output of following program 1

import numpy as np
d=np.array([100,200,300,400,500,600,700])
print(d[-6:-2])
Ans : [200 300 400 500] (1 mark for correct output)
b) Point out the incorrect statement: 1

A.__Both Series and ndarrays can be passed as arguments to Numpy functions.


B.__The major difference between Series and ndarray is that the data is arranged
based on label in Series, when Series is operated on.
C.__A DataFrame is similar to a fixed-size dict because you can use the index labels
to get and set values.
D.__None of the above.
Ans : Option C (1 mark for correct Option C )

c) Fill in the blank with appropriate numpy method to calculate and print the variance of 1
an array.

import numpy as np
data=np.array([10,20,30,40,50,60])
print(np. (data,ddof=0)

OR

Create an ndarray with values ranging from 10 to 40 each specified with a


difference of 3.

Page 1 of 17
Ans : print(np.var(data,ddof=0)) (1 mark for appropriate function var)

OR

import numpy as np (1 mark for appropriate arrange function)

Z=np.arange(10,40,3)

d) Explain the use of vsplit( ) function with syntax and example. 2


Ans : numpy.vsplit is a special case of split() function where axis is 1 indicating a vertical
split regardless of the dimension of the input array.

a = np.arange(16).reshape(4,4)
b = np.vsplit(a,2)
print b
(1 mark for correct use of vsplit( ), 1 mark for correct example.)
e) Write a Python programming code to display a bar chart of the popularity of 2
programming Languages.

Sample data:
Programming languages: Java, Python, PHP, JavaScript, C#, C++
Popularity: 22.2, 17.6, 8.8, 8, 7.7, 6.7

Ans : import matplotlib.pyplot as plt


x = ['Java', 'Python', 'PHP', 'JavaScript', 'C#', 'C++']
popularity = [22.2, 17.6, 8.8, 8, 7.7, 6.7]
x_pos = [i for i, _ in enumerate(x)]
plt.bar(x_pos, popularity)
(1/2 mark for each line of code) ( 2 mark for correct code or similar code)

f) What is series ?Explain with the help of an example. 2

Page 2 of 17
Ans : Pandas Series is a one dimensional labeled array capable of holding data of any
type(integer,string,float,python objects etc)

The axis labels are collectively called index.Example

import pandas as pd

data=pd.Series([1,2,3,4,5])

print(data)

(g) Write a Numpy program to find out smallest and sum of array elements 3
0,1,2,3,4,5,6,7,8,9.

OR

Write a python programming code to display and create a 8x8 ndarray and fill it
with a checkerboard pattern i.e. 0 and 1 at alternative positions.

Ans: import numpy as np 3

arr=np.array([0,1,2,3,4,5,6,7,8,9])#s1 marks
for
a=arr.min() #s2
correc
b=arr.sum() #s3
t code
print(a)

OR

import numpy as np

c=np.zeros((8,8),dtype=int)

c[1::2,::3]=1

c[::2,1::2]=1

Print(c)

Page 3 of 17
2 a) Which Pandas Dataframe function is used to get list from DataFrame column headers: 1
A. print(list(df.columns.values))
B. print(list(df.rows.values))
C. print(list(df.columns.index))
D. print(list(df.head))

Ans : OPTION A
b) Find the output of following program: 1

import pandas as pd

df = pd.DataFrame([[1, 2], [4, 5], [7, 8]],

index=['cobra', 'viper', 'sidewinder'],

columns=['max_speed', 'shield'])
Ans : 2
c) Explain Pandas iterrow(). Give example. 1
iterrows() − iterate over the rows as (index,series) pairs. Example :

df = pd.DataFrame(np.random.randn(4,3),columns = ['col1','col2','col3'])

for row_index,row in df.iterrows():

print row_index,row

d) Which method is used to compare two dataframe?


1
Ans : equals()

e) How does pivot-table differ() from pivot()? 2


Ans : pivot() is used for pivoting without aggregation. Therefor, it can’t deal with duplicate
values for one index/column pair. pivot_table is a generalization of pivot that can handle
duplicate values for one pivoted index/column pair. Specifically, you can give
pivot_table a list of aggregation functions using keyword argument aggfunc. The default
aggfunc of pivot_table is numpy.mean. ( 2 mark for correct answer.)

Page 4 of 17
f) Write a python code to create a dataframe as per given structure in the figure. 2

Country Rank

0 Russia 121

1 Colombia 40

2 Chile 100

3 Equador 130

4 Nigeria 11

OR

Write a small python code to create a dataframe with headings (sid, age) from the list given
below.

[ [‘S1’,20],[‘S2’,30],[‘S3’,40], [‘S4’,50] ]

Ans : import pandas as pd

data = pd.DataFrame({'Country': ['Russia','Colombia','Chile','Equador','Nigeria'],

'Rank':[121,40,100,130,11]}) ( 2 mark for correct answer.)

print(data)

OR

( 2 mark for correct answer.)

import pandas as pd

df1=pd.dataframe([‘S1’,20],[‘S2’,30] ],columns=[‘id’,’age’] ]

df2= pd.dataframe([‘S3’,40],[‘S4’,50] ],columns=[‘id’,’age’] ]

df1.=df1.append(df2)

Page 5 of 17
g) Consider the following dataframe, and answer the questions given below: 3

import pandas as pd
data = pd.DataFrame(np.arange(12).reshape((3, 4)),
index=['Ohio', 'Colorado', 'New York'],columns=['one', 'two', 'three', 'four'])
(i) Write the code to rename column name from 'Ohio' to 'SanF'.
(ii) Write the code to find mean value from above dataframedf over the
index and column axis. (Skip NaN value).
(iii) Use sum() function to find the sum of all the values over the index axis.

OR

Consider the following dataframe df and answer the questions given below:

import pandas as pd
 
df = pd.DataFrame([[10, 20, 30, 40], [7, 14, 21, 28], [55, 15, 8, 12],
                   [15, 14, 1, 8], [7, 1, 1, 8], [5, 4, 9, 2]],
                  columns=['Apple', 'Orange', 'Banana', 'Pear'],
                  index=['Basket1', 'Basket2', 'Basket3', 'Basket4', 'Basket5', 'Basket6'] )
 
i) Write a command to calculate minimum value for each of the columns

ii) Write a command to calculate maximum value for each of the rows

iii) Write a command to complete mean, mode and median

Ans : (i) data.rename(index = {'Ohio':'SanF'},


columns={'one':'one_p','two':'two_p'},inplace=True)
(ii) print(df.mean(axis = 1, skipna = True))
print(df.mean(axis = 0, skipna = True))
(iii) print(df.sum(axis = 1, skipna = True) ( 1 marks each,3 mark for correct answer.)

OR

Page 6 of 17
print("\n----------- Minimum -----------\n")
print(df[['Apple', 'Orange', 'Banana', 'Pear']].min())
 
print("\n----------- Maximum -----------\n")
print(df[['Basket1', 'Basket2', 'Basket3', 'Basket4',
                         'Basket5', 'Basket6']].max())

print("\n----------- Calculate Mean -----------\n")


print(df.mean())
 
print("\n----------- Calculate Median -----------\n")
print(df.median())
 
print("\n----------- Calculate Mode -----------\n")
print(df.mode())
( 1 marks each,3 mark for correct answer.)

h) Consider the following dataframe named carPriceDf , carsHorsepowerDf 3


and answer the questions given below:

Car_Price = {'Company': ['Toyota', 'Honda', 'BMV', 'Audi'], 'Price': [23845, 17995,


135925 , 71400]}
carPriceDf = pd.DataFrame.from_dict(Car_Price)

car_Horsepower = {'Company': ['Toyota', 'Honda', 'BMV', 'Audi'], 'horsepower': [141, 80,


182 , 160]}
carsHorsepowerDf = pd.DataFrame.from_dict(car_Horsepower)

Write the commands to do the following operations on the dataframes :


(i) To add dataframes carPriceDf and carsHorsepowerDf
(ii) To subtract carsHorsepowerDf from carPriceDf
(iii) To Merge two data frames, and append second data frame as a new column
to the first data frame.
Ans : (i) print((pd.concat([carPriceDf , carsHorsepowerDf]))
(ii) print(carPriceDf.subtract(carsHorsepowerDf))
(iii) carsDf = pd.merge(carPriceDf, carsHorsepowerDf, on="Company")
print(carsDf) ( 1 marks each,3 mark for correct answer.)

Page 7 of 17
i) Find the output of the following code: 4

import pandas as pd
import numpy as np
s1 = pd.Series(['100', '200', 'python', '300.12', '400'])
s2 = pd.Series(['10', '20', 'php', '30.12', '40'])
print("Data Series:")
print(s1)
print(s2)
df = pd.concat([s1, s2], axis=1)
print("New DataFrame combining two series:")
print(df)

Ans : Data Series:


0 100
1 200
2 python
3 300.12
4 400

0 10
1 20
2 php
3 30.12
4 40

New DataFrame combining two series:


0 1
0 100 10
1 200 20
2 python php
3 300.12 30.12
4 400 40

( 01 mark for correct output of print(s1), 01 mark for correct output of print(s2),
02 mark for correct output of print(df) )
Section B
Answer the following questions :

Page 8 of 17
3 a) Which of the following is NOT the phase consisting on spiral model of software 1
development.
A) Planning
B) Design
C) Engineering
D) Risk-Analysis

Ans : Option B
b) is the process of checkinq the developed software for its correctness and error free working 1

A. Specification
B. Desiqn/Implementation
C.Validation/Testing
D. Evolution

Ans : Option C
c) Write down any one benefit of version control. 1

Ans : merge all the changes into a common version. (1 mark for correct answer)
d) 2
What are differences between commit/update and push/pull requests ?
Ans : Commit refers to updating the file in local repository on a distributed version control system.
Push refers to updating the file in remote repository on a distributed version control

(2 mark for correct answer)


e) Explain waterfall model. Also mention one advantage and one disadvantage of waterfall 3

software process.

OR

Explain spiral delivery model. Also mention one advantage and one disadvantage of spiral
delivery

Page 9 of 17
Ans : The water fall model is a linear and sequential approach of software development where software
develops systematically from one phase to another in a downward fashion. The model is divided into
different phases and the output of one phase is used as input of next phase.
The phases are as follows:
1. Requirements specifications 2. Analysis and system design
3. Implementation and unit testing 4. Integration and system testing
5. Operation and maintenance
Advantage : Simple and easy to understand
Disadvantage : No working software till the last phase
3 marks (1 mark for explanation 1 mark for correct advantage and 1mark for correct
disadvantage)

OR
Spiral Model is a combination of a waterfall model and iterative model. Each phase in spiral
model begins with a design goal and ends with the client reviewing the progress.

Advantage- Additional functionality or changes can be done at a later stage


Cost estimation becomes easy as the prototype building is done in small fragments
Disadvantage-Risk of not meeting
3 marks (1 mark for explanation 1 mark for correct advantage and 1mark for correct
disadvantage)

f) What is agile software development? Give difference between traditional approach of


software development and agile methods.

OR

Define about scrum and pair programming used in agile software development.

Page 10 of 17
Agile software development

Agile software development refers to a group of software development methodologies based on


iterative development, where requirements and solutions evolve through collaboration between
self-organizing cross-functional teams.
Agile is a process that helps teams provide quick and unpredictable responses to the feedback they
receive on their project. It creates opportunities to assess a project's direction during
the development cycle. Teams assess the project in regular meetings called sprints or iterations.
The main difference between traditional and agile approaches is the sequence of project phases –
requirements gathering, planning, design, development, testing and UAT. In traditional development
methodologies, the sequence of the phases in which the project is developed is linear where as in
Agile, it is iterative. (2 mark for correct explanation of Agile software development
and 2 mark for difference )
OR

Scrum is an agile framework for managing knowledge work, with an emphasis on software
development, although it has wide application in other fields and is slowly starting to be explored by
traditional project teams more generally. It is designed for teams of three to nine members, who break
their work into actions that can be completed within time boxed iterations, called sprints, no longer
than one month and most commonly two weeks, then track progress and re-plan in 15-minute time
boxed stand-up meetings, called daily scrums.
Pair programming is an agile software development technique in which two programmers work
together at one workstation. One, the driver, writes code while the other, the observer or navigator
reviews each line of code as it is typed in. The two programmers switch roles frequently.
(11/2 mark for correct explanation of Scrum and 11/2 mark for correct explanation for Pair
programming )
g) Draw a use-case diagram for a online cab / taxi booking app. 4

OR

Draw a use-case diagram for a Bank ATM system.

Page 11 of 17
Ans :

(4 marks for correct use case diagram)

Section C
Answer the following questions :
4 a) Which command is used to create a new app named OLA in Django project? 1

Ans : python manage.py startapp OLA

Page 12 of 17
b) The COUNT function in SQL returns the number of ______________ 1

A. Values B. Distinct values

C. Group By D. Columns

OR

Which Command is used for changing values in Mysql table

A. Alter B. Update

C. Select D. Delete

Ans : Option A

OR

Update

c) Mandatory arguments required to connect any database from Python 1

A. Username, Password, Hostname, Database Name, Port.


B. Username, Password, Hostname
C. Username, Password, Hostname, Database Name
D. Username, Password, Database Name
Ans : Option C

d) What is the name of a special control structure that facilitates the row-by-row processing of
records in the result set during Python-MySQL connectivity? 1
Ans : Database cursor.
e) Which command is used for destroying table in mysql ? 1

Ans : Drop
f) The doc_name column of a table hospital is given below 3

Doc_name
Avinash
Ranjeet
Aman
Kushagra
Based on the information ,find the output of the following queries:
(i)Write mysql command to display Doc_name starting with letter ‘K’ having any
length.
(ii) Write mysql command to display Doc_name ending with letter ‘A’ having only four
character.
(iii) Write mysql command to change name ‘Aman’ by new name ‘Arun’.

Page 13 of 17
Member_id Member_nam Address Age Fees
Ans : (i)select doc_name from ehospital where doc_name like “K%”.
M001 Sumit New Delhi 20 1000
(ii) select doc_name
M002 from hospital
Nisha where doc_name
Gurgaon like “_
19_ _A”. 1500
M003 Niharika New Delhi 21
(iii)Update Hospital set Doc_name=’Arun’ where Doc_name=’Aman’; 2100
M004 Sachin Faridabad 18 1500
g) Observe the  3
table ‘Club’ given below:
Club

i.          What is the cardinality and degree of the above given table?
ii.        If a new column contact_no has been added and two more members have
joined the club then how these changes will affect the degree and
cardinality of the above given table.

iii. Write MySQL command to add a new column contact_no.

Ans : i.          Cardinality:4
Degree: 5
(½ mark for each correct answer)
ii.        Cardinality: 6
Degree: 6
(½ mark for each correct answer)
iii. Alter table Club add contact_no  varchar(20);
(1 Mark Each for queries from (i) to (iii) )

h) Consider the table FLIGHT given below. Write commands in SQL for (i) to (iv) and output 4
for (v) to (vi). ( queries from (i) to (iii)=1 Mark Each & from (iv) to (v)= ½ Mark Each)

((i) Display details of all flights starting from Delhi.


(ii) Display details of flights that have more than 4 number of flights operating.
(iii) Display flight codes, starting place, destination, number of flights in descending order
of number of flights.
(iv)Add on column “Remarks” in given table FLIGHT .
(v) SELECT MAX(NO_FLIGHTS) FROM FLIGHT;
(vi)SELECT START, COUNT(*) FROM FLIGHT GROUP BY Start;
Page 14 of 17
Ans : (i)select * from flight where start=’delhi’;
(ii) select * from flights where no_flights>4;
(iii) select flcode, start, destination, no_flights from flight order by no_flights desc;
(iv)Alter Table Flight add Remarks varchar(20)
(v) 7
(vi) DELHI 3
MUMBAI 2
KANPUR 1
INDORE 1

(1 Mark Each for queries from (i) to (iii), ½ Mark Each for correct output )
OR
(i)In a bank,a database named PNB is created in mysql whose password is
“123”.Reema is trying toad a new record of PNB having
details(‘E1’,’Meena’,’Delhi’) in a PNB table.
(ii)Write the python code to read the contents of “first.csv” file consisting of data from a
mysql table and print data of table on the screen in tabular form of table.

Ans.import mysql.connector
Mydb=mysql.connector.connect(host=”localhost”,user=”root”,passwd=”123”,
database=”PNB”)
mycursor=mydb.cursor()
mycursor.excute(“insert into PNB values(‘E1’,’Meena’,’Delhi’);”)
mydb.commit()
(ii)f=open(‘first.csv’,’r’)
with f:
reader =csv.reader(f)
for row in reader:
for e in row:
print(e)

Section D
Answer the following questions :
5 a) Vinod is preparing financial analysis report of its organisation. Can he copy and paste 1
information from the Internet for reference in his report?
Ans : Yes, he can do this but only after giving the reference to all the sources, otherwise it will be
treated as copyright violation.
b) What does the term “Intellectual Property Rights” covers? 1
Ans : The term “Intellectual Property Rights” covers Copyrights, Trademarks and Patents.
c) What are the environmental issues of e-waste? 1

Page 15 of 17
Ans : E-waste, or electronic waste, is waste from all sorts of electronics ranging from computers
and mobile phones, to household electronics such as food processors, pressure cookers, etc.
The effects of improper disposal of this e-waste on the environment are little known;
however, damage to the atmosphere is one of the biggest environmental impacts of e-waste.

d) What do you understand by the term Plagiarism? Write two software used as plagiarism 2
checker.
Ans : Plagiarism is “copying and publication” of another author’s “language, thoughts, ideas, or
expressions” and the representation of them as one’s own original work. Plagiarism is
considered academic dishonesty and a breach of journalistic ethics.
The software available for Plagiarism checker are:
(i) DupliChecker (ii) Grammarly (iii) Paperrater (iv) Plagiarisma

(1 mark for correct explanation of Plagiarism and 1 mark for two software)

(2 mark for correct answer)

e) List down some points about societal changes introduced by technology. 2


Ans : Technology is the application of scientific knowledge to the making of tools to solve
specific problems. Technological advances such as automobiles, airplanes, radio, television,
cellular phones, computers, modems, and fax machines have brought major advances and
changes to the world. (2 mark for correct answer)
f) What do you understand by Computer ethics? OR 3

Explain the role of online social media campaigns, crowdsourcing and smart mobs in
society.
Computer ethics are a set of moral principles that govern the behaviour of a group or an
individual and regulate the use of computers. These include intellectual property rights
(such as copyrighted electronic content), privacy concerns, and how computers affect our
society. (3 mark for correct answer)
OR

Role of Social Media Campaigns:-


A social media campaign should focus around a singular business goal, whether it's on
Facebook or Instagram. Common goals for a social media campaigns include:
 Getting feedback from users.
 Building email marketing lists
 Increasing website traffic

Crowdsourcing is the practice of engaging a ‘crowd’ or group for a common goal — often
innovation, problem solving, or efficiency. It is powered by new technologies, social media
and web 2.0. Crowdsourcing can take place on many different levels and across various
industries.

Smart mobs, so named because each person in the group uses technology to receive
information on where to go and what to do. This ability to stay on top of current events
makes smart mobs extremely effective
3 marks (1 mark for one correct role of social media campaign, 1 mark for one correct role
of Crowdsourcing and 1 mark for one correct role of Smart mob)
Page 16 of 17
Page 17 of 17

You might also like