0% found this document useful (0 votes)
16 views2 pages

Class XII Computer Science Test July 2019

The document is a test paper for class 12 computer science. It contains 17 questions related to functions, parameters, modules, packages, files and I/O in Python. The questions cover topics like defining and calling functions, passing arguments, scope of variables, errors in functions, difference between modules and packages, built-in help function, importing objects from modules, file I/O operations like reading, writing and random number generation.

Uploaded by

SvLab
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)
16 views2 pages

Class XII Computer Science Test July 2019

The document is a test paper for class 12 computer science. It contains 17 questions related to functions, parameters, modules, packages, files and I/O in Python. The questions cover topics like defining and calling functions, passing arguments, scope of variables, errors in functions, difference between modules and packages, built-in help function, importing objects from modules, file I/O operations like reading, writing and random number generation.

Uploaded by

SvLab
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

KENDRIYA VIDYALAYA NO.

1 AFS SAMBRA, BELAGAVI


MONTHLY TEST-II JULY 2019-20
CLASS XII
COMPUTER SCIENCE
[Link]: 35
TIME: 90MIN
_______________________________________________________________________________________________________________
ALL QUESTIONS ARE COMPULSORY.
Q.I
(1) What is the significance of having function in a program ? 2M
(2) From the program code given below, identify the parts mentioned below: 2M
def prcessNuumber(x):
x=72
return x+3
y=54
res=processNumber(y)

(3) Predict the output produced by it: 2M


def power(b, p):
y=b**p
return y
def calcsquare(x):
a=power(x, 2)
return a
n=5
result=calcsquare(n)+power(3, 3)
print(result)

(4) What do you understand by function? Write the types of function are there in python ? 2M
(5) Write the syntax for function declaration in Python. 1M
(6) What is the difference between the formal parameters and actual parameters ? What are their
alternative names ? Also, give suitable Python code to illustrate both . 3M
(7) What will be the output of following programs ?
a) num=1 b) def increment(n): 4M
def myfnc( ): [Link]([4])
global num return n
num=10 L=[1,2,3]
return num M=increment(L)
print(num) print(L, M)
print(myfunc( ) )
print(num)
(8) Find the errors in code given below: 4M
a) def minus(total, decrement) b) define check( )
output = total – decrement N=input(‘Enter N:’)
print(output) i=3
return(output) answer = 1+i**4/N
return answer
(9) What is package ? How is a package different from module ? 2M
(10) What is the utility of built-in function help() ? 1M

(11) Why should the from <module> import <object> statements be avoided to import objects ? 2M

(12) Consider the following code: 2M


import random
print(int (20 +[Link]( )*5),end=’ ’)
print(int (20 +[Link]( )*5),end=’ ’)
print(int (20 +[Link]( )*5),end=’ ’)
print(int (20 +[Link]( )*5))
Find the suggested output option (i) to (iv). Also, write the least value and highest value that can be
generated.

i)20 22 24 25 ii)22 23 24 25 iii) 23 24 23 24 iv) 21 21 21 21

(13) What is the difference between read( ) and readlines( ) function ? 2M


(14) Differentiate between the following :
a) f=open(‘[Link]’, ‘r’) b) f=open([Link]’, ’w’) 2M
(15) What is the output of following code fragment? Explain.
out=file(“[Link]”, ’w”)
[Link](“Hello, world!\n”)
[Link](“How are you?”)
[Link]( )
file(“[Link]”).read( )
(16) A text file contains alphanumeric text say “[Link]”. Write a program that reads this text file and prints
only the numbers or digits from the file. 2M
(17) Write code to print just the last line of a text file “[Link]” 2M

You might also like