MS-Computer Science-XII
MS-Computer Science-XII
RANCHI RAGION
FIRST PREBOARD EXAMINATION
COMPUTER SCIENCE (083)
CLASS XII
MAX MARKS-70 TIME: 3 hrs
MARKING ACHEME
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is given in Q35 against part c
only.
8. All programming questions are to be answered using Python Language only.
SECTION A
1 Identify the invalid Python statement from the following. 1
(a) _b=1 (b) __b1= 1 (c) b_=1 (d) 1 = _b
Ans – (d) 1 = _b
2 Identify the valid arithmetic operator in Python from the following. 1
(a) // (b) < (c) or (d) <>
(a) state [-5:] (b) state [4:] (c) state [:4] (d) state [:-4]
Page 1 of 13
if not False:
print(10)
else:
print(20)
Ans – (a) 10
8 Consider the Python statement: f.seek(10, 1) 1
Choose the correct statement from the following:
(a) file pointer will move 10 byte in forward direction from beginning of the file
(b) file pointer will move 10 byte in forward direction from end of the file
(c) file pointer will move 10 byte in forward direction from current location
(d) file pointer will move 10 byte in backward direction from current location
Ans: (c) file pointer will move 10 byte in forward direction from current location
9 Which of the following function returns a list datatype? 1
Ans: d) d=f.readlines()
10 Identify the device on the network which is responsible for forwarding data from one device to 1
another
16 Which of the following method is used to create a connection between the MySQL database and 1
Python?
Ans: (a) Both A and R are true and R is the correct explanation for A
18 Assertion (A): CSV files are used to store the data generated by various social media platforms. 1
Reason (R): CSV file can be opened with MS Excel.
Ans: (b) Both A and R are true and R is not the correct explanation for A
SECTION - B
19 Find error in the following code(if any) and correct code by rewriting code and underline the 2
correction;‐
Str = "Computer"
Str = Str[-4:]
print(Str*2)
Ans:
uteruter
OR
Consider the following lines of codes in Python and write the appropriate output:
Page 3 of 13
student = {'rollno':1001, 'name':'Akshay', 'age':17}
student['name']= “Abhay”
print(student)
Ans:
{'rollno': 1001, 'name': 'Abhay', 'age': 17}
21 What do you mean by Foreign key? How it is related with Referential Integrity? 2
Ans:
A foreign key is a non-key attribute whose value is derived from the primary key of another table.
The relationship between two tables is established with the help of foreign key. Referential
integrity is implemented on foreign key.
1 mark for explanation and 1 mark for relation with referential integrity.
22 Find output generated by the following code: 2
string="aabbcc"
count=3
while True:
if string[0]=='a':
string=string[2:]
elif string[-1]=='b':
string=string[:2]
else:
count+=1
break
print(string)
print(count)
Ans:
bbcc
4
23 Expand the following terms: 2
i. NIC
ii. TCP/IP
iii. POP
iv. SMTP
Ans:
i. Network Interface Card
ii. Transmission Control Protocol/ Internet Protocol
iii. Post Office Protocol
iv. Simple Mail Transfer Protocol
½ mark for each expansion
24 Write one advantage and one disadvantage of each – STAR Topology and Tree Topology 2
OR
What do you mean by Guided Media? Name any three guided media?
Ans –
Guided media – Physical Connection – ½ mark
Page 4 of 13
Twisted pair cable, Co-axial cable, Fiber-optic cable)
Ans:
Data Definition Language (DDL): This is a category of SQL commands. All the commands
which are used to create, destroy, or restructure databases and tables come under this category.
Examples of DDL commands are ‐ CREATE, DROP, ALTER.
Data Manipulation Language (DML): This is a category of SQL commands. All the commands
which are used to manipulate data within tables come under this category. Examples of DML
commands are ‐ INSERT, UPDATE, DELETE.
OR
Write the main difference between INSERT and UPDATE Commands in SQL
Ans:
INSERT used to insert data into a table.
UPDATE used to update existing data within a table.
SECTION - C
26 Write definition of a method/function AddOdd(VALUES) to display sum of odd values from the 3
list of VALUES
Ans:
def AddOdd(Values):
n=len(NUMBERS)
s=0
for i in range(n):
if (i%2!=0):
s=s+NUMBERS[i]
print(s)
Ans:
def SHOWWORD () :
c=0
file=open(‘STORY.TXT,'r')
line = file.read()
word = line.split()
for w in word:
if len(w)<5:
print( w)
file.close()
(½ Mark for opening the file)
(½ Mark for reading line and/or splitting)
(½ Mark for checking condition)
(½ Mark for printing word)
Page 5 of 13
OR
Write a user defined function in python that displays the number of lines starting with 'H' in the
file para.txt
Ans:
def count H( ):
f = open (“para.txt” , “r” )
lines =0
l=f. readlines ()
for i in L:
if i [0]== ‘H’:
lines +=1
print (“No. of lines are: “ , lines)
Ans:
(a) (b) (c)
Itemane MONTHNAME(Dateofstock) Price*DIscount
White lotus February 625000
Comfort Zone December 340000
Wood Comfort February 112500
Page 6 of 13
103 Table Tennis 4 8000 14‐Feb‐2004
105 Chess 2 9000 01‐Jan‐2004
108 Lawn Tennis 4 25000 19‐Mar‐2004
Write the output for the following queries :
(i) SELECT COUNT(DISTINCT Number) FROM GAMES;
(ii) SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROM GAMES;
(iii) SELECT SUM(PrizeMoney) FROM GAMES;
Ans:
(i) 2
(ii) 19‐Mar‐2004 12‐Dec‐2003
(iii)59000
30 Write PushOn(Book) and Pop(Book) methods/functions in Python to add a new Book and delete 3
a Book from a list of Book titles, considering them to act as push and pop operations of the Stack
data structure.
Ans:
def PushOn(Book):
a=input(“enter book title :”)
Book.append(a)
def Pop(Book):
if (Book = =[ ]):
print(“Stack empty”)
else:
print(“Deleted element :”)
Book.pop()
OR
Mr.Ajay has created a list of elements. Help him to write a program in python with functions,
PushEl(element) and PopEl(element) to add a new element and delete an element from a List of
element Description, considering them to act as push and pop operations of the Stack data
structure . Push the element into the stack only when the element is divisible by 4.
Ans:
N=[12, 13, 34, 56, 21, 79, 98, 22, 35, 38]
def PUSHEl(S,N):
S.append(N)
def POPEl(S):
if S!=[]:
return S.pop()
else:
return None
ST=[]
for k in N:
if k%4==0:
PUSH(ST,k)
while True:
Page 7 of 13
if ST!=[]:
print(POP(ST),end=" ")
else: break
SECTION - D
31 India Tech Solutions (ITS) is a professional consultancy company. The company is planning 5
to set up their new offices in India with its hub at Hyderabad. As a network adviser, you
have to understand their requirement and suggest them the best available solutions. Their
queries are mentioned as (i) to (v) below.
FINANCE BLOCK
(i)Which will be the most appropriate block, where TTC should plan to install their server?
(ii) Draw a block to block cable layout to connect all the buildings in the most appropriate
manner for efficient communication.
(iii)What will be the best possible connectivity out of the following, you will suggest to
connect the new set up of offices in Bengalore with its London based office.
Satellite Link
lInfrared
Ethernet
(iv)Which of the following device will be suggested by you to connect each computer in
each of the buildings?
l Switch
l Modem
l Gateway
(v) Company is planning to connect its offices in Hyderabad which is less than 1 km. Which
type of network will be formed?
Ans:
(i) TTC should install its server in finance block as it is having maximum number of
computers.
(ii) Any suitable lyout
(iii) Satellite Link.
(iv) Switch.
Page 8 of 13
(v) LAN
The Following program code is used to increase the salary of Trainer SUNAINA by 2000.
Page 9 of 13
Ans:
Statement 1 – mycon.cursor ( )
Statement 2 – execute(sql).
Statement 3- mycon.commit ( )
OR
(a) Write the output of the following Python program code: 2
my_dict = {}
my_dict[(1,2,4)] = 8
my_dict[(4,2,1)] = 10
my_dict[(1,2)] = 12
sum = 0
for k in my_dict:
sum += my_dict[k]
print (sum)
print(my_dict)
The Following program code is used to view the details of the graduate whose subject is
PHYSICS.
Ans:
Statement 1 – mysql.connector
Statement 2 –. mycon.cursor ( )
Statement 3- mycon.close( )
33 Sumit is a programmer who is working on a project that requires student data of a school to 5
be stored in a CSV file. Student data consists of roll no, name, class and section. He has
written a program to obtain the student data from user and write it to a CSV file. After
getting errors in the program he left five statements blank in the program as shown below.
Help him to find the answer of the following questions to find the correct code for missing
statements.
#Incomplete Code
import_____ #Statement 1
fh = open(_____, _____, newline=‘ ’) #Statement 2
stuwriter = csv._____ #Statement 3
data = []
header = [‘ROLL_NO’, ‘NAME’, ‘CLASS’, ‘SECTION’]
data.append(header)
for i in range(5):
roll_no = int(input(“Enter Roll Number : ”))
name = input(“Enter Name : ”)
Class = input(“Class : ”)
section = input(“Enter Section : ”)
rec = [_____] #Statement 4
data.append(rec)
stuwriter. _____ (data) #Statement 5
fh.close()
(i) Identify the suitable code for blank space in line marked as Statement 1.
(ii) Identify the missing code for blank space in line marked as Statement 2.
(iii) Choose the function name (with argument) that should be used in the blank space of line
marked as Statement 3.
(iv) Identify the suitable code for blank space in line marked as Statement 4.
(v) Choose the function name that should be used in the blank space of line marked as
Statement 5 to create the desired CSV file?
Ans.
(i) csv
(ii) “Student.csv”,“w”
(iii) writer(fh)
(iv) roll_no,name,Class,section
(v) writerows()
OR
Page 11 of 13
What are the advantages of binary file over text file? Write a Python program in Python to
search the details of the employees (name, designation and salary) whose salary is greater
than 5000. The records are stored in the file emp.dat. consider each record in the file emp.dat
as a list containing name, designation and salary.
Ans.
In binary file, there is no terminator for a line and the data is stored after converting it into
machine understandable binary language. A binary file stores the data in the same way as
stored in the memory. Like text file we can’t read a binary file using a text editor.
----------------- 2 marks (any suitable difference)
import pickle as p
L=[]
with open(‘emp.dat’,’rb’) as f:
L=p.load(f)
for r in L:
if r[2]>5000:
print(“name=”,r[0])
print(“designation=”,r[1])
print(“salary=”,r[2])
----------------3 marks (any suitable code)
SECTION - E
34 Based on given table “DITERGENTS” answer following questions.
PID PName Price Category Manufacturer
1 Nirma 40 Detergent Powder Nirma Group
2 Surf 80 Detergent Powder HL
3 Vim Bar 20 Disc washing Bar HL
4 Neem Face Wash 50 Face Wash Himalaya 1
a) Write SQL statement to display details of all the products not manufactured by HL. 1
b) Write SQL statement to display name of the detergent powder manufactured by HL. 2
c) Write SQL statement to display the name of the Product whose price is more than 0.5
hundred.
OR
c) Write SQL statement to display name of all such Product which start with letter
‘N’
Ans:
or
c) Select Pname from DITERGENTS where left(pname) = ‘N’;
35 Arun is a class XII student of computer science. The CCA in-charge of his school wants to 1+1+2
display the words form a text files which are less than 4 characters. With the help of his
computer teacher Arun has developed a method/function FindWords() for him in python
which read lines from a text file Thoughts. TXT, and display those words, which are lesser
than 4 characters. His teachers kept few blanks in between the code and asked him to fill the
blanks so that the code will run to find desired result. Do the needful with the following
python code.
Page 12 of 13
def FindWords():
c=0
file=open(‘NewsLetter.TXT’, ‘_____’) #Statement-1
line = file._____ #Statement-2
word = _____ #Statement-3
for c in word:
if _____: #Statement-4
print(c)
_________ #Statement-5
FindWords()
Ans:
(i) r
(ii) read()
(iii) line.split()
(iv) len(c)<4
Page 13 of 13