You are on page 1of 5

SAMPLE PAPER-I Class XII (Computer Science) Periodic Test-2

Blueprint
S.NO. NAME OF CHAPTERS TOTAL MARKS VSA(1 SA(2 MARKS) LA(3 MARKS)
MARKS)
1 NETWORKING 5 3 2(4)
2 CYBER SAFETY 1 1
3 FUNCTION 19 4(8) 3(9)
4 RECURSION 8 1(2) 2(6)
5 FILE HANDLING 7 2(4) 1(3)
4 18 18
UNIT TEST- II
CLASS XII
SUBJECT : COMPUTER SCIENCE

Time : 90 mins Max Marks : 40

Note: a) All questions are compulsory.


b) Give examples wherever possible.
Q1. Describe ipconfig command and ping command in terms of networking (2)
Q2. Find the error (if any) in the following code and write the corrected code and (2)
underline it :
Def sum(a,b)
returna+b
print “The sum =” Sum(7,-1)
Q3. Describe the following: (4)
a) Protocol b) Topology c) phishing d) FTP
Q4. Find the output of the following python code : (4)
a) def upgrade(a,b=2): b) def show(x,y=2):
a=a+b print(ord(x)+y)
print(a+b) show('A')
i,j=10,20 show('B',3)
upgrade(i,5)
upgrade(i)

Q5. State the advantages of using functions in python. (2)


Q6. State the use of global keyword. Give an example to illustrate its use. (3)
Q7. State keyword argument with example in python (2)
Q8. Write a program using user defined function to :
a) Check if
a number entered by the user to check whether a number is prime or not (3)
b) Calculate and display average of all the elements in a user defined list (3)
containing numbers.
Q9. Write the difference between r+ and w+ mode of file opening in python (2)
Q10. Write a program in python to count number of words stored in a text file (3)
Q 11 if a file “sample.txt” contains the following lines. Based on this answer the following (2)
welcome to the world of python
f=open("sample.txt")
f.seek(12,0)
str=f.read(2)
print(str)
f.seek(0,0)
str=f.read(7)
print(str)
Q12 . Describe recursion. (2)
Q 13. Why recursive function is slower than iterative function (3)
Q 14 . Write a function to print the factorial of number using recursion (3)
MARKING SCHEME:
1. In Windows, ipconfig is a console application designed to run from the Windows command prompt.
This utility allows usto get the IP address information of a Windows computer.
2.

Def sum(a,b) def sum(a,b):


return a+b return a+b
print “The sum =” Sum(7,-1) print("The sum =", sum(7,-1))
3. …
Protocol :- it is a set of rules which governs flow of data in network, ex tcp/ip, http, ftp
Topology :- physical arrangement of device in network is called toplogy, ex star, bus
Phishing :-it often directs users to enter personal information at a fake website which matches the
look and feel of the legitimate site.
FTP:- it is protocol used for uploading and downloading file from network/internet

4. a) 20
14
(b) 67
69
5. Advantages of using function are:
i. Reusability of code
ii. Makes the program maintenance easy
iii. Improve the readability of program
iv. Reduce design cost /time
6. if local and global variable name are same then global keyword is used to access the global variable
.
x = "global"
deffunc():
global x
print(x)
x = "local"
print(x)
func()
output:-
global
local
7. keyword argument: This allows us to skip arguments or place them out of order because the Python
interpreter is able to use the keywords provided to match the values with parameters.
Ex.
defprintinfo( name, age ):
"This prints a passed info into this function"
print "Name: ", name
print "Age ", age
return;
# Now wecan call printinfo function
printinfo( age=50, name="miki" )
8. program
a) b)
def prime(n): defavg(a):
count=0 sum=0
h=n//2 count=0
for i in range(2,h): for i in a:
if n%i==0: sum=sum+i
count+=1 count+=1
if count==0: average=sum/count
print("prime") print(average)
else: l=[1,2,3,4,8]
print("not prime") avg(l)

9. difference between r+ and w+

R+ W+
Opens a file for both reading and writing. The Opens a file for both writing and reading.
file pointer placed at the beginning of the file. Overwrites the existing file if the file exists. If the
file does not exist, creates a new file for reading
and writing.

10. Program to count word in a text file


c=0
f1=open("a.txt")
for w in f1.read().split():
c=c+1
print("word count ",c)
f1.close()
11. Output is:
he
welcome
12. Recursion : Recursion is a method of programming or coding a problem, in which a function calls
itself one or more times in its body
13. recursion doesn't remember previously calculated values. Hence it is slower than iterative function.
Ex

14. Program of fcatorial using recursion:-


def factorial(n):
if n == 1: return 1
else: return n * factorial(n-1)

You might also like