0% found this document useful (0 votes)
93 views13 pages

CS Answers - 2019-20 - SET2

The document contains instructions and questions for a pre-board computer science examination. It is divided into 4 sections (A, B, C, D) covering different units. Section A contains 6 multiple choice questions covering Python functions, variables, dictionaries, and code syntax. Section B contains 2 questions on list declarations and operations. Section C contains 3 questions on efficiency, reading/parsing a text file, and insertion sort. Section D contains 2 longer questions involving recursion, binary search, and implementing a stack with city details.

Uploaded by

-Uddipan Bagchi
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)
93 views13 pages

CS Answers - 2019-20 - SET2

The document contains instructions and questions for a pre-board computer science examination. It is divided into 4 sections (A, B, C, D) covering different units. Section A contains 6 multiple choice questions covering Python functions, variables, dictionaries, and code syntax. Section B contains 2 questions on list declarations and operations. Section C contains 3 questions on efficiency, reading/parsing a text file, and insertion sort. Section D contains 2 longer questions involving recursion, binary search, and implementing a stack with city details.

Uploaded by

-Uddipan Bagchi
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/ 13

BANGALORE SAHODAYA SCHOOLS COMPLEX

PREBOARD EXAMINATION FOR CLASS- XII : 2019-2020


COMPUTER SCIENCE – NEW (083)
SET II
MAX MARKS : 70 TIME : 3 HOURS

GENERAL INSTRUCTIONS

● All questions are compulsory.


● Question paper is divided into 4 sections A, B, C and D.
 Section A : Unit-1
 Section B : Unit-2
 Section C : Unit-3
 Section D : Unit-4

PART A
Q1 a) Identify and write the name of the module to which the following functions belong: 1
(i) uniform()
(ii) fabs()

Ans. (i) uniform() - random module


(ii) fabs() - math module

b) Which of the following can be used as valid variable identifier(s) in Python? 1


My.file, _countS, For, 2digits, 4thSu, Total, Number#, Name2

Ans. Valid Identifier are _countS, For, Total, Name2

c) Specify any two ways to remove an element from a dictionary? 1


Ans. • <dictionary>.pop(<key>) method
• del <dictionary>[<key>] command

d) Rewrite the following code in python after removing all syntax error(s). Underline each 2
correction done in the code.
def chksum:
x= input("Enter a number")
if (x%2 = 0):
for i range(2*x):
print(i)
loop else:
print("#")

Ans. Corrected Code:


def chksum():
x= int(input("Enter a number"))
if (x%2 == 0):
for i in range(2*x):
print(i)

Page 1 of 13
else:
print("#")

e) Find the output of the following code: 2


def CALLME(n1=2, n2=4):
n1= 2* n1*n2
n2+=2
print(n1, "\t", n2)
CALLME()
CALLME(2,1)
CALLME(3)

Ans. 16 6
4 3
24 6

f) Write the output of the following Python program code: 3


Inp = "a3bc%"
res = ""
lenTnd= -1
for s in Inp:
if s.isdigit():
res = res + Inp[lenTnd] * 2
elif s.isalpha():
res = res + Inp[lenTnd] * 3
else:
res = res + Inp[lenTnd] * 1
lenTnd = lenTnd – 1
res = res + „#‟
print(res)

Ans. Output will be: %%%#cc#bbb#333#a#

g) Observe the following program and find out, which output(s) out of (i) to (iv) will be 2
expected from the program? What will be the minimum and the maximum value
assigned to the variable alter?

import random
Ar= [10, 7]
alter = random.randint(0,2) + 10;
for C in range(0,2):
print(Ar[C] + alter, end = " # ")

i) 22 # 19# ii) 16 # 19 # iii) 20 # 17 # iv) 23 # 19 #

Ans: Output will be either ii) or iii)


Max value of alter : 11 Min value of alter: 10

Q2 a) Which of these are valid declarations? 1


i) A=1,2,3
ii) B = (1,2,3)
iii) A, B, C = (1,2)
iv) A, B, C = tuple(“xyz”)

Page 2 of 13
Ans: i) , ii) and iv)

b) Find the output from the following code: 1


L=[100,200,300,400,500]
L1=L[2:4]
L2=L[1:5]
L2.extend(L1)
print(L2)
L[2:3] = [1,2]
print(L)

Ans: [200, 300, 400, 500, 300, 400]


[100, 200, 1, 2, 400, 500]

c) Reorder the following efficiencies from the largest to the smallest: 1


a) 2n b) n! c) n5 d) 10,000 e) nlog2(n)

Ans: 10,000 > nlog2(n) > n5 > 2n > n!

d) A text file “MyFile.txt” contains alphanumeric text. Write a program that reads this text file 2
and prints only the numbers or digits from the file.

Ans :
F = open("MyFile.txt ", "r")
for line in F:
words = line.split()
for i in words:
for letter in i:
if(letter.isdigit()):
print(letter)

e) Write a program to sort a sequence using Insertion Sort technique. 2

Ans: lst = [14,18,9,17,22,13]


l = len(lst)
print("The given list is:", lst)
for i in range(1,l):
k = lst[i]
j=i-1
while j >= 0 and k < lst[j]:
lst[j+1] = lst[j]
j -= 1
else:
lst[j+1] = k
print("The sorted list using Insertion Sort technique:", lst)

f) Write a recursive function that computes the series; 1+4+9+ …n 2 where the value of 3
the n is given by the user

Ans: def compute(num):

Page 3 of 13
if num == 1:
return 1
else:
return(num * num + compute(num - 1))

# main function
n = int(input("Enter the number : "))
res = compute(n)
print("The sum of the series is :",res)

OR

Write a python function to search for a string in the given list using binary search
method. Function should receive the list and a string to be searched as arguments and
return index if the value is found -1 otherwise

Ans:
#Binary Search
def BS(l,ll,ul,s):
if ll > ul:
return -1
else:
m = (ll + ul)//2 #ll + (ul - ll) //2
if l[m] > s:
return BS(l,ll,m-1, s)
elif l[m] < s:
return BS(l, m+1, ul,s)
else:
return m

def main():
lst = eval(input("Enter the list :"))
se = eval(input("Enter the search element:"))
#lst.sort()
p = BS(lst,0,len(lst)-1,se)
if p < 0 :
print("Not found")
else:
print("Found at ", p)

main()

g) Write a program to implement a stack for these city_details(pincode, cityname). That 3


is, now each node of the stack contains two types of information – city name and its
pincode. Implement Push and Pop operations.

Ans: # Stack implementation

def isEmpty(stk):
if stk == []:

Page 4 of 13
return True
else:
return False

def Push(stk,item):
stk.append(item)
top = len(stk) - 1

def Pop(stk):
if isEmpty(stk):
print("Stack empty")
else:
top = len(stk) - 1
del stk[top]

def Display(stk):
if isEmpty(stk):
print("Stack empty")
else:
top = len(stk) - 1
print(stk[top])
for a in range(top-1,-1,-1):
print(stk[a])

# __main__
Stack = []
top = None
while True:
print("STACK OPERATIONS :")
print("1. PUSH")
print("2. POP")
print("3. EXIT")
ch = int(input("Enter your choice (1 - 5) :"))
if ch == 1:
pin = int(input("Enter city pincode to be inserted :"))
cname = input("Enter city name to be inserted :")
item = [pin,cname]
Push(Stack,item)
Display(Stack)
elif ch == 2:
Pop(Stack)
Display(Stack)
elif ch == 3:
break
else:
print("Invalid Choice")
OR

Write a program to perform Enque and Deque operations on a Queue containing


Employee details as given in the following definition of itemnode :
EmployeeId integer
EmployeeName String
PhoneNo integer

Page 5 of 13
Ans: def Enque(queue,item):
queue.append(item)

def Deque(queue):
if (queue==[]):
print("Queue empty")
else:
print("Deleted element is: ",queue[0])
del queue[0]
#Calling function
que = []
cont = True
while cont == True:
print("Enter 1 to add new employee :")
print("Enter 2 to remove an employee :")
ch = int(input("Enter your choice :"))
if ch == 1:
print("For the new employee, enter details below:")
eId = int(input("Enter employee id :"))
eName = input("Enter employee name :")
ePhone = int(input("Enter employee's phone number :"))
ele = [eId,eName,ePhone]
Enque(que,ele)
else:
Deque(que)
print("The updated list is :", que)
c = input("Do you want to continue... (Y/N)? ")
if c.upper( ) == 'N':
cont = False

h) Give postfix form of the following expression showing in a tabular form the 2
changing status of the stack:
(A* B) - (C+ D) / E

Ans: Evaluation order is; ((A * B ) - (C+D)) / E)

Element Output to be printed


(
A A
* A
B AB
- AB*
( AB*
C AB*C
+ AB*C
D AB*CD
) AB*CD+ -
/ AB*CD+ -
E AB*CD+ - E
) AB*CD+ - E/

Page 6 of 13
i) Write a code to create a pie chart for Rainfall = [180,220,140,150,110] for Zones 3
= ['East','West','North','South','Central']
i) Show North zone‟s value exploded
ii) Show % contribution for each zone
iii) The pie chart should be circular

Ans:
import matplotlib.pyplot as plt
Rainfall = [180,220,140,150,110]
Zones = ['East','West','North','South','Central']
plt.axis("equal")
plt.pie(Rainfall,labels = Zones, explode = [0,0,0.2,0,0], autopct = "%1.1f%%")
plt.show()

OR

Draw a graph for the code given below:


import matplotlib.pyplot as plt
import numpy as np
Y = [[3, 8, 5, 7], [5, 12, 3, 8]]
X = np.arange(4)
plt.bar(X,Y[0],color = 'g',width = 0.3,label = 'Production in Jan')
plt.bar(X+0.3, Y[1],color = 'y',width = 0.3,label = 'Production in Feb)
plt.legend(loc='upper left')
plt.show()
Ans:

PART B
Q3 a) ____________ is a device that connects dissimilar networks 1

Ans: A Gateway OR A Router

b) Name the type of error occurs when two or more nonconsecutive bits in data got 1
changes from 0 to 1 or from 1 to 0

Ans: Multiple-bit error

c) A teacher provides “https://www.XtSchool.com/default.aspx” URL to his/her 1


students. Help them in identifying the Protocol & domain name.

Ans: PROTOCOL: HTTPS


Domain name: XtSchool.com

Page 7 of 13
d) Kabir wants to purchase a Book online and placed the order for that book using an 1
ecommerce website. Now, he is going to pay the amount for that book online using his
Mobile, he needs which of the following to complete the online transaction :
i) A bank account
ii) A Mobile connection/phone which is attached to above bank account,
iii) The mobile banking app of the above bank installed on that mobile
iv) Login credentials (UserId & Password) provided by the bank,
v) All of above

Ans: (v)

e) Write the expanded forms of the following abbreviated terms used in networking and 2
communications:
i) FTP
ii) WiFi
iii) IoT
iv) DNS

Ans:
i) FTP - File Transfer Protocol
ii) WiFi - Wireless Fidelity
iii) IoT - Internet of Things
iv) DNS - Domain Name System

f) What is the difference between PING and TRACERT(TRACEROUT) commands? 2

Ans: PING command tests the connectivity between two hosts whereas TRACEROUT
command shows the number of hops and response time to connect to a remote system or
website.

g) Explain the following terms: 3


i) Public Clouds
ii) Switches
iii) Fiber Optic Cable or Optic Fiber Cable

Ans:
i) These are the clouds for use by multiple organizations (tenants) on a shared
basis and hosted and managed by a third-party service provider.
ii) Switches work similarly like Hubs but in a more efficient manner. It creates
connections dynamically and provides information only to the requesting port.
Switch is a device in a network which forwards packets in a network.
iii) A fiber optic cable consists of a bundle of glass threads, each of which is
capable of transmitting messages modulated onto light waves. Common types
of Fiber Optic Cables are single node and multi-node.

h) Rehaana Medicos Center has set up its new center in Dubai. It has four buildings as shown 4
in the diagram given below:

Page 8 of 13
Distances between various buildings are as follows:
Accounts to Research Lab 55 m
Accounts to Store 150m
Store to Packaging Unit 160 m
Packaging Unit to Research Lab 60 m
Accounts to Packaging Unit 125 m
Store to Research Lab 180 m

Number of computers:
Accounts 25
Research Lab 100
Store 15
Packaging Unit 60

As a network expert, provide the best possible answer for the following queries:
i) Suggest a cable layout of connections between the buildings.
ii) Suggest the most suitable place (i.e. buildings) to house the server of this
organization.
iii) Suggest the placement of the following device with justification:
a) Repeater b) Hub/Switch
iv) Suggest a system (hardware/software) to prevent unauthorized access
to or from the network.

Ans: i) Layout 1

OR
Layout 2

Page 9 of 13
ii) The most suitable place/ building to house the server of this organization would be
building Research Lab, as this building contains the maximum number of
computers. For layout1, since the cabling distance between Accounts to Store is
quite large, so a repeater would ideally be needed along their path to avoid loss of
signals during the course of data flow in this route. For layout2, since the cabling
distance between Store to Research Lab is quite large, so a repeater would ideally
be placed.

iii) In both the layouts, a Hub/Switch each would be needed in all the buildings to
interconnect the group of cables from the different computers in each building.

iv) Firewall

PART C
Q4 a) Observe the table „Club‟ given below: 1

Member_id Member_Name Address Age Fee


M001 Sumit New Delhi 20 2000
M002 Nisha Gurgaon 19 3500
M003 Niharika New Delhi 21 2100
M004 Sachin Faridabad 18 3500

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

Ans: Cardinality: 7, Degree: 6

b) Is NULL value the same as 0? Give the reason 1

Ans: No. NULL value specifies a legal empty value whereas 0 is a number having the
value Zero.

c) Name the commands used to perform the below mentioned tasks: 1


i) to display the structure of a table
ii) to display the current system date

Ans:
i) DESCRIBE or DESC
ii) CurDate()

d) Mr. Mittal is using a table with following columns: Name, Class, StreamName 1
He needs to display names of students who have not been assigned any stream. He

Page 10 of 13
wrote the following command, which did not give the desired result.
SELECT Name, Class FROM Students WHERE StreamName = NULL;
Help Mr. Mittal to run the query by removing the error and write the correct query.

Ans : SELECT Name, Class FROM Students WHERE StreamName IS NULL;

e) Write the commands used to perform the below tasks: 2


i) to fetch a user defined number of rows from a database table.
ii) to return the number of rows retrieved through the fetch..() methods of the
cursor.

Ans: i) data = cur.fetchmany(num)


ii) cnt = cur.rowcount

f) Write the commands to create a Django project “School” and two apps “Students” and 2
“Teachers”.

Ans: django-admin startproject School


Python manage.py startapp Students

g) Consider the tables given below: 4


Table: Staff
StaffId Name Dept Gender Experience
1125 Noopur Sales F 12
1263 Kartik Finance M 6
1452 Palak Research F 3
236 Nayana Sales F 8
366 Anvashan Finance M 10
321 Sawan Sales M 7

Table : Salary
StaffId Basic Allowance CommPer
1125 14000 1500 9
1263 25000 2800 6
236 13500 1400 5
321 12000 1500 5
366 26100 3100 12

Write SQL commands :


i) To display names and departments of staff members with minimum 10years of
experience
ii) To display average salary of all staff members
(Salary = Basic + allowance)
iii) To display details of female staff members from sales department
iv) To update Basic salary by 10% for all staff members whose name starts with „N‟

Ans:
i) SELECT Name. Dept FROM Staff WHERE Experience >= 10;
ii) SELECT AVERAGE(Basic + Allowance) From Staff S1, Salary S2 WHERE
S1.StaffId = S2.StaffId;
iii) SELECT * FROM Staff WHERE Gender = „F‟ AND Dept = „Sales‟;
iv) UPDATE Staff SET Basic = 1.10 * Basic WHERE Name LIKE „N%‟;

Page 11 of 13
h) Consider the tables given in 4(g) and write the outputs for below queries: 3
i) SELECT Name FROM Staff WHERE Gender = „M‟ ORDER BY Name DESC;
ii) SELECT Dept, Count(StaffId) from Staff Group By Dept ;
iii) SELECT * FROM Salary WHERE CommPer BETWEEN 6 TO 12;
Ans :
v)
Name
Palak
Noopur
Nayana
vi)
Dept Count(StaffId)
Sales 3
Finance 2
Research 1
vii)

StaffId Basic Allowance CommPer


1125 14000 1500 9
1263 25000 2800 6
366 26100 3100 12

PART D
Q5 a) Standard security protocol that establishes encrypted links between a web server and 1
a browser is called _______________

Ans: Secure Socket Layer Technology

b) Which of the following fall under the category of cyber-crime: 1


i) Online Gambling
ii) Posing defamatory messages on social media
iii) Downloading copyrighted movies through torrents
iv) Selling herbal products online.

Ans : ii) and iii)

c) Differentiate between Digital property and Intellectual property. 2

Ans : Digital property is any information about you or created by you that exists in
digital form, either online or on an electronic storage device.
Intellectual Property is the creative creations of mind such as patents, literary and
creative arts, copyrights, trademarks etc.

d) How can we recycle e-waste safely? 2


Ans : (Any four)
i) Use a certified e-waste recycler.
ii) Visit civic institutions. Check with your local government, schools and universities
for additional responsible recycling options.
iii) Explore retail options.
iv) Donate your electronics.

Page 12 of 13
e) Arun opened his e-mail and found that his inbox was full of hundreds of unwanted mails. It 2
took him around two hours to delete these unwanted mails and find the relevant ones in his
inbox. What can Arun do to prevent this happening in future?
Ans: Prevention measure that Arun can implement are:
i) Download spam filtering tools and anti-virus software
ii) Make Use of Email Security Measures
iii) Unsubscribe to Unwanted Messages
iv) Never give out or post his email address publicly
v) Do not reply to spam messages
(Any two)

f) How can special needs of differently abled students be met while teaching 2
computers?
Ans: (Any two)
i) Schools must work towards making available the required teaching
aids/materials to fulfill special needs of students with disabilities.
ii) School must employ special needs teachers and should also train other teachers
as well about how to interact with students with special needs so as to help them
learn in a better inclusive way.
iii) There should be special budget allocated for buying the required material and
equipment to promote inclusive education and also for training the staff about
such needs.
iv) Schools must support the inclusive curriculum

Page 13 of 13

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy