12 CS PT 0301 Ans

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

VEDIC VIDYASHRAM SENIOR SECONDARY SCHOOL

TIRUNELVELI-627 358
(Academic Year : 21-22)
Grade : XII COMPUTER SCIENCE (083) CODE : PT-0301
Time : 1.30 hrs Max : 35

General Instructions:
1. The question paper is divided into 3 Sections - A, B and C.
2. Section A, consist of 20 Questions. Attempt all questions.
3. Section B, consist of 20 Questions. Attempt all questions.
4. Section C, consist of 5 case study based Questions. Attempt all questions.

PERIODIC TEST-3
SECTION-A
Each carry 0.5 Marks ( 20 * 0.5 = 10)
A function in python begins with which keyword?
01 a) void b) return c) int d) def
What is the output of the expression:
02 round(4.576)
a) 4.5 b) 5 c)4 b) 4.6

03 What is the output of the functions shown below? >>>m in(m ax(False, -3,-4), 2,7)
a) 2 b) False c) -3 d) -4
Which of the following functions does not throw an error?
04
a) ord() b) ord(‘ ‘) c) ord(”) d) ord(“”)
How many keyword arguments can be passed to a functionin a single function call?
05
a) zero b) one c) zero or more d) one or more
What is returned by
06 >>> math.ceil(3.4)?
a)3 b) 4 c) 4.0 d) 3.0
What is returned by
07 >>> math.ceil(-3.4)?
a) 3 b) 4 c) 4.0 d) -3
What is output of print(math.pow(3, 2))?
08
a) 9 b) 9.0 c) None d) None of these
What is the output of the code shown below?
import random
09 random.choice(2,3,4)
a)An integer other than 2, 3 and 4 b) Either 2, 3 or 4
c) Error d) 3 only
_________keyword is used to return a value to calling function.
10 a) void b) func c) return d) None

11 A function can return ____ number of value to calling function

1
a) one b) Two c) Three d) Multiple
A function that does not return a value is known as ________
12
a) friend function b) user defined function c) void function d) None
__________function returns the smallest integer greater than the given floating point number.
13
a) floor() b) ceil() c) sqrt() d) abs()
A function is a _________ that acts on data and often returns a value
a) main program
14 b) sub program
c) library
d) package
Which values are used by the functions to communicate information back to the caller?
a) local
15 b) global
c) return
d) random
A variable created or defined within a function body is classified as:
a) local
16 b) global
c) built- in
d) instance
Which of the following keywords marks the beginning of the function block?
a) func
17 b) define
c) def
d) function
Which of the following function calls will cause Error while invoking the below function
definition?
def test(a, b, c, d)
18 a) test(1, 2, 3, 4)
b) test(a = 1, 2, 3, 4)
c) test(1,2,c=3,d=4)
d) test(a = 1, b = 2, c = 3, d = 4)
Which of the given argument types can be skipped from a function call?
a) positional arguments
19 b) keyword arguments
c) named arguments
d) default arguments
Python passes parameters by _____.
20 a) Value b) Variable c) String d) Reference
SECTION-B ( 20 * 1 = 20)
What is the output of the following snippet?
def fun (n):
if (n > 100):
21 return n - 5
return fun (fun (n+11))
print (fun (45))
a) 50

2
b) 100
c) 74
d) Infinite loop
Fill in the line of code for calculating the factorial of a number:
def fact (num):
if num == 0 :
return 1
else:
22
return __________
a) num*fact(num-1)
b) (num-1)*(num-2)
c) num*(num-1)
d) fact(num)*fact(num-1)
Which of the following function headers is not correct?
a) def f(a = 1, b=2):
23 b) def f(a = 1, b, c = 2):
c) def f(a = 1, b = 1, c = 2):
d) def f(a , b = 1, c = 2, d=6):
Functions that do not return any value are known as:
a) fruitful functions
24 b) void functions
c) library functions
d) user-defined functions
What is the output of the program given below?
x = 50
def func (x) :
x=2
func (x)
25
print ('x is now', x)
a) x is now 50
b) x is now 2
c) x is now 100
d) Error
_____ arguments are the named arguments with assigned values being passed in the function call
26 statement.
a) positional b) keyword c) default d) None
What is the result of this code?
def print_double(x):
print(2 ** x)
print_double(3)
27
a) 8
b) 6
c) 4
d) 10
Which of the following function calls can not be used to invoke the below function definition?
def test(a, b, c, d)
a) test(1, 2, 3, 4)
28
b) test(a = 1, 2, 3, 4)
c) test(1,b = 2, c = 3, d=4)
d) test(a = 1, b = 2, c = 3, d = 4)
3
What are the outcomes of the following functions?
chr(‘97’)
29
chr(97)
a) Error and ‘a’ b) ‘a’ c) Error d) None
What is the output of the function shown below?
list(enumerate([2, 3]))
30
a) Error b) [(1, 2), (2, 3)]
c) [(0, 2), (1, 3)] d) [(2, 3)]
What is the output of the functions shown below?
divmod(10.5,5)
31 divmod(2.4,1.2)
a) (2.00, 0.50) and (2.00, 0.00) b) (2, 0.5) and (2, 0)
c) (2.0, 0.5) and (2.0, 0.0) d) (2, 0.5) and (2)
The output of the function:
float(' -12345\n')
(a) -12345.0
32
b) -12345.0
c) Error
d) -12345.000000000….
Which of the following is the use of function in python?
a) Functions are reusable pieces of programs
33 b) Functions don’t provide better modularity for your application
c) you can’t also create your own functions
d) All of the mentioned
What is the output of the below program?
x = 525
def func(x):
print('x is', x)
x=2
34
print('Changed local x to', x)
func(x)
print('x is now', x)
a) x is now 525 b) x is now 2
c) x is now 200 d) None of the mentioned
What is the output of below program?
def say(message, times = 1):
print(message * times)
say('Hello')
35 say('World', 5)
a) Hello and WorldWorldWorldWorldWorld
b) Hello and World 5
c) Hello and World,World,World,World,World
d) Hello and HelloHelloHelloHelloHello
What is the output of below program?
def maximum(x, y):
if x > y:
36 return x
elif x == y:
return 'The numbers are equal'
else:
4
return y
print(maximum(2, 3))
a) 2 b) 3 c) The numbers are equal d) None of the mentioned
Which are the advantages of functions in python?
a) Reducing duplication of code
37 b) Decomposing complex problems into simpler pieces
c) Improving clarity of the code
d) All of the mentioned
What is the output of below program?
def cube(x):
return x * x * x
38
x = cube(3)
print x
a) 9 b) 3 c) 27 d) 30
What is the output of the below program?
def sum(*args):
'''Function returns the sum of all values'''
r=0
for i in args:
r += i
39 return r
print(sum())
print (sum(1, 2, 3))
print (sum(1, 2, 3, 4, 5))
a) 6 and 15 b) 6 and 100
c) 123 and 12345 d) None of the mentioned

Python supports the creation of anonymous functions at runtime, using a construct called
__________
a) Lambda
40
b) pi
c) anonymous
d) None of the mentioned
SECTION-C
Match the columns:
A B
1. max() a. will compute x**y
2. sqrt(x) b. will select a option random ly
41
3. choice() c. will return the largest value
4. pow(x,y) d. will compute (x)1/2
a) 1-a,2-b,3-c,4-d c) 1-c,2-d,3-b,4-a
b) 1-d,2-a,3-c,4-b d) 1-b,2-c,3-d,4-a
def Interest(p,c,t=2,r=0.09):
42 return p*t*r
Considering the above defined function which of following function call are legal.
5
1. Interest(p=1000,c=5)
2. Interest(r=0.05,5000,3)
3. Interest(500,t=2,r=0.05)
4. Interest(c=4,r=0.12,p=5000)
a) 1 , 2 and 4 b) 2 & 3 c) 1 &4 d) 3 & 4
Consider the statement given below and answer the question:
>>>S=’My name is Ravindra’
Which statement will print “True” out of the given :
43 a) print(S.isspace( ))
b) print (s.isspace( ))
c) print(S[2].isspace)
d) print(S[2].isspace( ))
What is the output of the function shown below if the random module has already been imported?
>>>import random
>>>random.randint(3.5,7)
44 a) Error
b) Any integer between 3.5 and 7, including 7
c) Any integer between 3.5 and 7, excluding 7
d) The integer closest to the mean of 3.5 and 7
How are required arguments specified in the function heading?
a) identifier followed by an equal to sign and the default value
45 b) identifier followed by the default value within backticks (“)
c) identifier followed by the default value within square brackets ([ ])
d) identifier
*********

You might also like