Professional Documents
Culture Documents
MS-Computer Science-12-Practice Paper - 1
MS-Computer Science-12-Practice Paper - 1
MS-Computer Science-12-Practice Paper - 1
SECTION B
def fact(num):#error1 not D instead lowercase d 2
19 factorial = 1
if num < 0:
print("Sorry, factorial does not exist for negative numbers")
elif num == 0 ) #error2 not else it is elif
print("The factorial of 0 is 1")
else:
for i in range(1,num + 1):
factorial = factorial*i#error3 indentation error
print("The factorial of",num,"is",factorial)#error4 indentation error
Award ½ march each error
1
CHENNAI SAHODAYA SCHOOLS COMPLEX
20 Router 2
Connects to a modem via a WAN port.
Also creates a local network between connected devices.
Connects to the internet.
Splits one internet connection to many devices.
Connects local devices to each other and the internet.
Switch
Connects to a router.
Used within a LAN to connect devices to each other and to the router.
Unsafe to connect directly to the internet.
Several switches can be connected to one router.
Only connects local devices to each ot her.
(or)
Connection In a bus topology, all the In star topology, all the nodes are
of nodes nodes are connected to a connected to a central controller
single communication line called a hub with a dedicated
with the help of drop lines and point-to-point link.
taps.
calls over the internet instead of traditional phone lines or cellular connection
Award 1 mark for correct ans
24 [5, 11, 12] [5, 11, 12] yes same shallow copy 2
1 mark for output and 1 mark for the description
OR
i) (9, 10, 5, 6, 7)
ii) Predict the output? 4
Award 1 mark for each output
25 CHAR Data Type VARCHAR Data Type 2
It stores values in fixed lengths and VARCHAR stores values in variable length
are padded with space characters to
along with 1-byte or 2-byte length prefix
match the specified length
and are not padded with any characters
OR
SQL aggregate functions includes AVG(), COUNT(), MIN(), MAX(), and SUM().
COUNT (): This function returns the number of records (rows) in a table.
The Syntax of the Select count (Desig) from employee.
SUM (): This function returns the sum of all values of a column in a table.
Here is the syntax select sum( salary) from employee
AVG () This function will return the average of all values present in a column.
The syntax of the select AVG (salary) from employee.
MIN (): This function produces the lowest value in a column for a group of rows that satisfy
a given condition
Award ½ mark for each difference and at least two differences award full mark
SECTION C
3
CHENNAI SAHODAYA SCHOOLS COMPLEX
27 def count_words(): 3
file = open("myfile.txt","r")
count = 0
for i in file.read():
if i.isdigit():
count += 1
print("Total words are",count)
count_words()
def count_words():
4
CHENNAI SAHODAYA SCHOOLS COMPLEX
file = open("myfile.txt","r")
count = 0
count1=0
i=file.read()
j=i.split()
for k in j:
if k== "my":
count += 1
elif k== "me":
count1 += 1
print("Total words my and me are",count,count1)
28 l=eval(input(“enter”))
for ptr in range(2):
while True:
l[ptr],l[ptr+2]=l[ptr+2],l[ptr]
ptr+=4
if ptr>len(l)-3:
break
print(l)
5
CHENNAI SAHODAYA SCHOOLS COMPLEX
6
CHENNAI SAHODAYA SCHOOLS COMPLEX
7
CHENNAI SAHODAYA SCHOOLS COMPLEX
SECTION E
33 Award one mark for each correct answer 5
34 a) 3+2
0,@6,@7,@8,@9,@25,@11,@
0,@6,@7,@8,@9,@
0,@6,@7,@
b) mycursor=mydb.cursor() statement1
rq=’’’insert into Employee (Empno, Ename, Design,Salary)
mycursorexecute(rq)#statement 3
mydb.commit()#statement4
8
CHENNAI SAHODAYA SCHOOLS COMPLEX
35 a. i)tell() function will tell where the file pointer. Update operation 5
Award one mark for correct answer
b. 1. f.seek(offset,mode)
Award one mark for correct answer
import pickle
def create():
f=open('s.dat','wb' )
ans='y'
while ans.lower()=='y':
admno=int(input("Enter Student ID: "))
name=input( "Enter Student Name: ")
clas=input("Enter class: ")
ans=input("Do you want to add more recods ?")
sturec=[admno,name,clas]
pickle.dump(sturec,f)
f.close()
def count():
file =open( "s.dat",'rb')
m=0
while True:
try:
data=pickle.load(file)
if data[1][0]=='A':
print(data)
if data[2]=='xii':
m=m+1
except:
file.close()
return m
create()
print(count())
Award ½ mark for opening a file
Award ½ mark for input the dta
Award ½ mark for writing into the file
Award ½ mark for opening a file
Award ½ mark for a reading and check appropriate condition
Award ½ mark for printing from the file
a. pickle.dump(python object,file object) this dump function will write into binary a file
pickle. Load(ile objectf) function read from the binary file.
Award one mark for the purpose dump and load function
Award one mark for writing the syntax
b. import pickle
def create():
f=open('animal.dat','wb')
ans='y'
while ans.lower()=='y':
animalname=input("Enter animalname ID: ")
animaltype=input( "Enter animaltype: ")
animalfood=input("Enter animalfood: ")
ans=input("Do you want to add more recods ?")
anirec=[animalname,animaltype,animalfood]
pickle.dump(anirec,f)
f.close()
9
CHENNAI SAHODAYA SCHOOLS COMPLEX
def copy():
data=[]
file =open ( 'animal.dat','rb' )
f=open('animal1.dat','wb')
while True:
try:
data=pickle.load(file)
print(data)
if data[2]=='grass':
pickle.dump(data,f)
print(data)
except:
file.close()
f.close()
create()
copy()
Award ½ mark for opening a file
Award ½ mark for input
Award ½ mark for writing into the file
Award ½ mark for opening a file
Award ½ mark for reading and check appropriate condition
Award ½ mark for printing from the file
10