0% found this document useful (0 votes)
46 views12 pages

CS Answers - 2019-20 - SET1

The document contains instructions for a pre-board examination for Class XII Computer Science. It provides general instructions that the paper is divided into 4 sections (A-D) covering different units. It then lists 6 sub-questions under Section A, requiring students to write code, identify outputs, functions, and variables. The questions test understanding of Python concepts like functions, loops, dictionaries, sorting algorithms and recursion.

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)
46 views12 pages

CS Answers - 2019-20 - SET1

The document contains instructions for a pre-board examination for Class XII Computer Science. It provides general instructions that the paper is divided into 4 sections (A-D) covering different units. It then lists 6 sub-questions under Section A, requiring students to write code, identify outputs, functions, and variables. The questions test understanding of Python concepts like functions, loops, dictionaries, sorting algorithms and recursion.

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/ 12

BANGALORE SAHODAYA SCHOOLS COMPLEX

PREBOARD EXAMINATION FOR CLASS- XII : 2019-2020


COMPUTER SCIENCE – NEW (083)
SET I
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) ceil()
ii) match()
Ans. i) ceil() – math module
ii) match() – re module

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


My.file, _count, For, 2digits, 4thSu, Total, Number#, Name1

Ans. Valid Identifier are _count, For, Total, Name1

c) What are two ways to remove an element from a list? 1


Ans. • <list>.pop(<index>) method
• <list>.remove(<value>) method

d) Rewrite the following code in python after removing all syntax error(s). Underline each 2
correction done in the code.
x=int(“Enter value for x:”))
for y in range[0,11]:
if x=y:
print(x+y)
else:
Print(x-y)

Ans. Corrected Code:


x=int(input(“Enter value for x:”))
for y in range(0,11):
if x==y:
print(x+y)
else:
print(x-y)

Page 1 of 12
e) Find the output of the following code: 2
def CALLME(n1=1, n2=2):
n1=n1*n2
n2+=2
print(n1, n2)
CALLME()
CALLME(2,1)
CALLME(3)

Ans. 2 4
2 3
6 4

f) What will be the output of the following program: 3


Text = "Work@is#Worship!"
ln = len(Text)
nText= ""
for i in range (0, ln):
if Text[i].isupper():
nText = nText + Text[i].lower()
elif Text[i].isalpha():
nText = nText + Text[i].upper()
else:
nText = nText + 'A'
print (nText);

Ans: wORKAISAwORSHIP

g) Observe the following program and answer the questions that follow: 2
import random
import random
x=3
n = random.randint(1,x)
for i in range(n):
print(i, '#', i+1)
i) What is the minimum and maximum number of times the loop will execute?
ii) Find out, which line of output(s) out of (i) to (iv) will not be expected from
the program?
i. 0#1 ii. 1#2 iii. 2#3 iv. 3#4

Ans: i) minimum = 1 and maximum = 3


ii) Only (iv)

Q2 a) Which is the correct form of declaration of dictionary? 1


i) Month = {1:‟January‟,2:‟February‟,3:‟March‟}
ii) Month = (1; ‟January‟,2; 2:‟February‟,3; ‟March‟)
iii) Month = [1: ‟January‟,2: ‟February‟,3: ‟March‟]
iv) Month = {1, ‟January‟,2, ‟February‟,3,‟March‟]

Ans: i) Month = {1:‟January‟,2:‟February‟,3:‟March‟}

Page 2 of 12
b) What is the output of the following program: 1
def myfunc(a):
a = L + [2]
for i in range(0,len(L)):
L[i]=L[i]*2
return sum(L)

L=[4,8,9]
print(myfunc(L))

Ans: 42
c) Reorder the following efficiencies from the smallest to the largest: 1
i) 2n ii) n! iii) n5 iv) 10,000 v) nlog2(n)

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

d) Write a function remove_lowercase( ) that accepts two file names, and copies all lines that 2
do not start with a lowercase letter from the first file into the second.

Ans:
def remove_lowercase(infile, outfile) :
print(infile,outfile)
output = open(outfile, "w+")
for line in open(infile) :
if not line[0] in "abcdefghijklmnopqrstuvwxyz" :
output.write(line)
output.close()

#Main function
f1 = input("Enter first file name:")
f2 = input("Enter second file name:")
remove_lowercase(f1,f2)

e) Consider the following unsorted list : 95 79 19 43 52 3 2


Write the passes of bubble sort for sorting the list in ascending order till the 4th
iteration.
79 19 43 52 3 95
Ans:
19 43 52 3 79 95
19 43 3 52 79 95
19 3 43 52 79 95
f) Write a recursive function that computes the sum of numbers 1…n; get the value 3
of the last number n from the user

Ans: def compute(num):


if num == 1:
return 1
else:
return(num + compute(num - 1))

# main function
n = int(input("Enter the number : "))

Page 3 of 12
res = compute(n)
print("The sum of the series from 1..",n," is :",res)

OR

Write a python function to search for a value in the given list using binary search method.
Function should receive the list and value 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 = int(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 book_details(bookno, bookname). 3


That is, now each node of the stack contains two types of information – a book
number and its name. Implement Push and Pop operations.

Ans: # Stack implementation

def isEmpty(stk):
if stk == []:
return True
else:
return False

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

Page 4 of 12
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 insert and delete operations on a Queue containing


Members details as given in the following definition of itemnode :
MemberNo integer
MemberName String
Age integer

Ans:
def InsertItem(queue,item):
queue.append(item)

def DeleteItem(queue):
if (queue==[]):
print("Queue empty")

Page 5 of 12
else:
print("Deleted element is: ",queue[0])
del queue[0]

#Calling function
que = []
cont = True
while cont == True:
print("Enter 1 to add a member :")
print("Enter 2 to delete a member :")
ch = int(input("Enter your choice :"))
if ch == 1:
print("For the new member, enter details below:")
mNo = int(input("Enter member no :"))
mName = input("Enter member name :")
mAge = int(input("Enter member's age :"))
ele = [mNo,mName,mAge]
InsertItem(que,ele)
else:
DeleteItem(que)
print("The updated list is :", que)
c = input("Do you want to continue... (Y/N)? ")
if c.upper( ) == 'N':
cont = False

h) Evaluate the following postfix expression using a stack and show the contents of 2
stack after execution of each operation:
120, 45, 20, +, 25, 15, -, +, *
Ans: 9000
Element Stack Contents
120 120
45 120, 45
20 120, 45, 20
+ 120, 65
25 120, 65, 25
15 120, 65, 25, 15
- 120, 65, 10
+ 120, 75
* 9000
i) Write a Python code to plot the below graph: 3

Page 6 of 12
Ans : import matplotlib.pyplot as plt
import numpy as np
p = np.array([1,2,3,4])
plt.bar(p, p**2, width = 0.3, label = 'Range1')
plt.bar(p+0.3, p*2, width = 0.3, label = 'Range2')
plt.legend(loc='upper left')
plt.show()
OR

Draw a graph for the code given below:


import matplotlib.pyplot as plt
Con = [23.4,17.8,25,34,40]
Zones = ['East','West','North','South','Central']
plt.axis("equal")
plt.pie(Con,labels = Zones, explode = [0,0.1,0.2,0,0], autopct = "%1.1f%%")
plt.show()

Ans:

PART B
Q3 a) _______________ is a device that links two networks together and can handle 1
networks that follow same protocols.

Ans: A bridge

b) Sum of data bits calculated from digital data that is used to ensure the data 1
integrity at the receiver‟s end is called ___________

Ans: CheckSum

c) What is Internet of Things? 1

Ans: IoT is a phenomenon that connects smart devices to the Internet over wired
or wireless connections.

d) What is Cloud computing? 1

Ans: Cloud computing is Internet-based computing whereby shared resources,


software, and information are provided to computers and other devices on demand.
It is use of the Internet for tasks you perform on your computer for storage, retrieval
and access. The delivery of computing services from a remote location through
Internet is called as cloud computing.

Page 7 of 12
e) Write the expanded forms of the following abbreviated terms used in networking and 2
communications:
i) SMTP
ii) POP
iii) GSM
iv) DNS

Ans:
i) SMTP - Simple Mail Transfer Protocol
ii) POP - Post Office Protocal
iii) GSM - Global System for Mobile
iv) DNS - Domain Name System

f) What is a collision in a network? What measures do wireless networks employ to 2


avoid collisions?

Ans: In a computer network, collision is a specific condition that occurs when two
or more nodes on a network transmit data at the same time. In case of a collision,
the data gets garble and cannot be read.
The wireless networks employ a protocol called CSMA/CA (Carrier Sense
Multiple with Collision Avoidance) to avoid collisions in the network.

g) Explain the following terms: 3


i) URL with a suitable example
ii) IP address with a suitable example
iii) Whois
Ans:
i) URL : Uniform Resource Locator is a location on a net server.
eg: http://cbse.nic.in
ii) IP address : Internet Protocol is a unique numerical label as a string of numbers
separated by dots, used to identify a device on the internet.
eg: 192.217.64.1
iii) Whois : is a networking command used for registration records for a specific
domain name such as owner‟s name, date of registration, valid upto, etc.

h) Hi-Standard Tech Training Ltd is a Mumbai based organization which is expanding its office 4
set- up to Chennai. At Chennai office compound, they are planning to have 3 different blocks
for Admin, Training and Accounts related activities. Each block has a number of computers,
which are required to be connected in a network for communication, data and resource sharing.
As a network consultant you have to suggest the best network related solution for the
queries (i) to (iv) as per the distances between various blocks and other given parameters.

Chennai Office

Mumbai
Admin Accounts
Block Head Office
Block

Training

Block

Page 8 of 12
Distances between various Blocks are as follows:
Admin to Accounts 300 m
Accounts to Training 150 m
Admin to Training 200 m
Mumbai Head office to Chennai 1300 km
Office

Number of Computers
Accounts 30
Training 150
Admin 40

i) Suggest the most appropriate block to house the server in the Chennai office.
Justify your answer.

ii) Suggest the best wired medium and draw the cable layout to efficiently connect
various blocks within the Chennai office compound.

iii) Suggest the device/software and its placement that would provide data security to
the entire network of the Chennai office.

iv) Suggest a device and the protocol that shall be needed to provide wireless Internet
access to all Smartphone / laptop users in the Chennai office.

Ans:
(i) Training Block is the most appropriate location to house the server as it has the
maximum number of computers.

(ii)
Admin Accounts
Block
Block

Training

Block

(iii) Suggested device is firewall. It will be placed where all messages are
entering or leaving the entire network.
(iv) Device: WiFi card Protocol: TCP/IP

PART C
Q4 a) Ms Krupa has created a table „Employee‟ that has 8 rows and 5columns. She deleted 3 1
rows and added 2 more columns. What is the Cardinality and Degree of the resulting
table?

Ans: Cardinality : 6
Degree : 7

Page 9 of 12
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) i) Which SQL function is used to count the number of unique elements in a column of 1
a table?
ii) Which SQL command is used to put a condition in a GROUP BY clause?
Ans:
i) COUNT(DISTINCT Columnname)
ii) HAVING

d) Ramesh wants to write a python script to connect to MySQL database with the credentials: 2
Server: „localhost‟
User Name: „Ramesh‟
Password: „Pass123‟
Database: „School‟
i) Write a python statement for him to connect to the MySQL server with the given
details.
ii) Write a python statement to create a cursor object named „ncursor‟
Ans:
i) con = mysql.connector.connect(host=‟localhost‟, user=‟Ramesh‟,
passwd=‟Passq123‟, database=School‟)
ii) ncursor = con.cursor()

e) Write a query to delete a column „PhoneNo‟ from the table „Customers‟ 1

Ans: ALTER TABLE Customers DROP COLUMN PhoneNo;

f) Write a view function that can process a GET request and display “main.html” as 2
template. Required file(s) and method(s) are already imported.

Ans: def display(request):


Return render(request, “main.html”)

g) Consider the table „Watches‟ given below. 4


WATCHES
Watchid Watch_Name Price Type Qty_Store
W001 HighTime 10000 Unisex 100
W002 LifeTime 15000 Ladies 150
W003 Wave 20000 Gents 200
W004 HighFashion 7000 Unisex 250
W005 GoldenTime 25000 Gents 100

Write SQL commands for the queries


i) To display id and names of all watches whose name ends with „Time‟
ii) To display all the details of those watches sorted in descending order by price;
iii) To delete all details of Unisex watches from the above table
iv) To increase the price of all watches by 10% whose Qty_Store is less than 150

Page 10 of 12
Ans:
i) SELECT Watchid, Watch_Name WHERE Watch_Name LIKE „%Time‟
ii) SELECT * FROM WATCHES ORDER BY Price DESC;
iii) DELETE FROM Watches WHERE Type = „Unisex‟;
iv) UPDATE Watches SET Price = Price + Price * 0.1 WHERE Qty_Store < 150;

h) Consider the table „Watches‟ given in question 4(g). 3


i) SELECT DISTINCT(Type) FROM Watches;
ii) SELECT Watch_Name, Price, Qty_Store FROM Watches WHERE Qty_Store
BETWEEN 150 AND 250;
iii) SELECT AVG(Price) FROM Watches GROUP BY Type

Ans :
i)
DISTINCT(Type)
Unisex
Ladies
Gents
ii)
Watch_Name Price Qty_Store
LifeTime 15000 150
Wave 20000 200
HighFashion 7000 250

iii)
AVG(Price)
8500
15000
225000

PART D
Q5 a) ___________________ is stealing someone else‟s intellectual work and representing 1
it as your own work without giving credits.

Ans: Plagiarism

b) Which out of the following does not come under Cyber Crime? 1
i) Copying data from the social networking account of a person without his/her
information & consent.
ii) Deleting some files, images, videos, etc. from a friend‟s computer with his consent.
iii) Viewing & transferring funds digitally from a person‟s bank account without
his/her knowledge.
iv) Intentionally making a false account on the name of a celebrity on a social
networking site.

Ans : ii)
c) Define the terms: 2
i) Computer forensic
ii) Identity theft

Page 11 of 12
Ans :
i) Computer forensic – refers to methods used for interpretation of computer media
for digital evidence.
ii) Identity theft – Online identity theft is the theft of personal information in order to
commit fraud.

d) Discuss Gender issues that you see in the field of computer studies 2

Ans: The major gender issues at school level computer science education are:
i) Under representation – the reasons are; Preconceived notations like boys are better
at technical things and girls in humanities, Lack of interest, Lack of motivation, Lack
of role models and lack of Encouragement in class.
ii) Non Girl-friendly Work Culture – Boys prefer to work with boys, Boys are not
comfortable in situations where they are not playing active roles, problems faced by
girls like „insufficient access time‟, „difficulty in maintenance‟ etc.

e) Mention two benefits of Technology in the economic sector. 2


Ans:
 Secure transaction
 Global e-Market
 Net Banking
 ATMs
(Any two)

f) Mention any four benefits of e_Waste recycling. 2

Ans: (Any four)


i) Allows for recovery of valuable precious metals.
ii) Protects public health and water quality.
iii) Creates jobs
iv) Saves landfill space
v) Toxic Waste

Page 12 of 12

You might also like