0% found this document useful (0 votes)
695 views

Class Test of Function Output

This document contains a 13 question computer science test with multiple choice and short answer questions about Python functions. Questions cover topics like function headers, flow of execution, function outputs, global variables, lists, sets, filtering, and string manipulation.

Uploaded by

Gaming School
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
695 views

Class Test of Function Output

This document contains a 13 question computer science test with multiple choice and short answer questions about Python functions. Questions cover topics like function headers, flow of execution, function outputs, global variables, lists, sets, filtering, and string manipulation.

Uploaded by

Gaming School
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

HERMANN GMEINER SCHOOL BHIMTAL

CLASS TEST SUBJECT-COMPUTER SCIENCE


SUBJECT-XII CHAPTER –FUNCTIONS
DATE: 19-04-2023 MM-25
Q1:Which of the following function headers is correct? (1)
A. def fun(a = 5, b =4, c)
B. def fun(a = 5, b, c =4)
C. def fun(a, b = 5, c = 4)
D. def fun(a, b, c = 4, d)

Q2:Consider the following program. What is the correct flow of execution of statements?(1)
1 def fun1(m, n):
2 c=m+n
3 print(c)
4 return c
5 x = 10
6 y = 20
7 fun1(x,y)
8 print(“OK”)
(A) 1,2,3,4,5,6,7,8
(B) 5,6,7,1,2,3,4,8
(C) 5,6,1,2,3,4,7,8
(D) 7,8,1,2,3,4,5,6

Q3:What is the output of following program? (1)


import math
a=math.ceil(20.5)
b=a/5
c=math.floor(b)
print(c)
OR

Which is NOT the possible output of following program from given options:
import random
periph = ['Mouse', 'Keyboard', 'Printer','Monitor']
for i in range(random.randint(0,2)):
print(periph[i],'*',end=" ")
(A) Mouse *Keyboard *
(B) Mouse *
(C) Mouse *Keyboard* Printer*
(D) No output
Q4: What is the output of following program? (2)
def greet(x):
if x < 0:
return "Welcome!"
else:
return "Namaste"
print(greet(1))
print(greet(-1))

Q5:What is the output of following program? (2)


g=0
def fun1(x,y):
global g
g=x+y
return g
def fun2(m,n):
global g
g=m-n
return g
k=fun1(2,3)
fun2(k,7)
print(g)
Q6:import random (2)
AR=[20,30,40,50,60,70]
FROM=random.randint(1,3)
TO=random.randint(2,4)
for K in range(FROM,TO+1):
print (AR[K],end=”#“)
(i) What will Be the minimum value of the variables FROM and TO?
(ii)What possible outputs(s) are expected to be displayed on screen at the time of execution of the
program?
(i) 10#40#70# (ii) 30#40#50#
(iii) 50#60#70# (iv) 40#50#70#
Q7:What is the output of following program? (2)
values = [1, 2, 3, 4]
numbers = set(values)
def checknums(num):
if num in numbers:
return True
else:
return False
for i in filter(checknums, values):
print i
OR
def func(a, b=5, c=10):
print('a is', a, 'and b is', b, 'and c is', c)
func(3, 7)
func(25, c = 24)
func(c = 50, a = 100)
Q8:What is the output of the below program? (2)
def sum(*args):
'''Function returns the sum of all values'''
r=0
for i in args:
r += i
return r
print (sum(1, 2, 3))
print (sum(1, 2, 3, 4, 5))

Q9:Write the output of the code given below: (2)


Val=100
def display (N):
global Val
Val=100
If Val%2==0:
Val=Val**N
else:
Val=Val*N
print (Val, end=”$”)
display (2)
print (Val)
Q10:Shristi has written a Python program to add all the numbers of the list. Her code has some errors.
Rewrite the correct code and underline the corrections made.
define sum (n=5,numbers):
total = 0
for x in numbers
total += x+n
returns total
print (sum (14, 6, 3, 5, 61))

Q11:What is the output of the below program? (2)


def printMax(a, b):
if a > b:
print(a, ‘is maximum’)
elif a == b:
print(a, ‘is equal to’, b)
else:
print(b, ‘is maximum’)
printMax(3, 4)

Q12:Write the output of the code given below: (3)


def Findoutput():
L= "Learn and Earn"
x=””

count = 1
for i in L:
if i in ['a', 'e',' i', 'o','u']:
x=x+1.swapcase ()
else:
if (count 2!=0):
x = x + str(len (L[:count]))
else:
count = count + 1 print (x)
Findoutput ()
Q13:Write the output of the code given below: (3)
s="welcome2cs"
n = len(s)
for i in range (0, n):
if (sli) >= 'a' and s[i] <= 'm'):
m = m+s[i].upper ()
elif (s[i]> 'n' and s[i] < 2):
m = m+s[i-1]
elif (s[i].isupper()):
m-m+s[i].lower ()
else:
print (m)

OR
Predict the output of the code given below:

def Change (s):


k = len(s)
for i in range (0, k) :
if(s[i].isupper()):
memes[i].lower ()
elif s[i].isalpha():
m-m+a[i].upper()
else:
print (m)
Change (IPv6 128-bit')

You might also like