0% found this document useful (0 votes)
34 views4 pages

XII-CS (Ch. 3 Working With Functions ASSIGNMENT-3)

Uploaded by

sharma20keshav
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)
34 views4 pages

XII-CS (Ch. 3 Working With Functions ASSIGNMENT-3)

Uploaded by

sharma20keshav
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
You are on page 1/ 4

DELHI PUBLIC SCHOOL, BAREILLY

XII- Computer Science


ASSIGNMENT-3
(CHAPTER 3: Working with Functions)
1. What will be the output of the following program:
num = 1
def func ( ) :
num = 3
print (num)
func ( )
print (num)

2. What will be the output of the following program:


def myfunc (text , num) :
while num > 0 :
print ( text )
num = num - 1
myfunc ( 'Hello' , 4)

3. Predict the output of the Python code given below :

4. What will be the output of the following code?


def Display(str):
m=""
for i in range(0,len(str)):
if(str[i].isupper()):
m=m+str[i].lower()
elif str[i].islower():
m=m+str[i].upper()
else:
if i%2==0:

Page 1 of 4
m=m+str[i-1]
else:
m=m+"#"
print(m)
Display('[email protected]')

5. Consider the code given below:


b=100
def test(a):
______________ # missing statement
b=b+a
print(a,b)
test(10)
print(b)
Which of the following statements should be given in the blank for #Missing Statement,
if the output produced is 110?
a) global a b) global b=100 c) global b d) global a=100

6. What will be the output of the following code?


L = [5,10,15,1]
G=4
def Change(X):
global G
N=len(X)
for i in range(N):
X[i] += G

Change(L)
for i in L:
print(i,end='$')

7. What will be the output of the following program:


def addFunc ( item ):
item += [ 1 ]
mylist = [ 1 , 2 , 3 , 4 ]
addFunc (mylist)
print ( len (mylist) )

8. Write the output for the execution of the following Python code :
def change(A):
S=0
for i in range(len(A)//2):
S+=(A[i]*2)
return S
B = [10,11,12,30,32,34,35,38,40,2]
Page 2 of 4
C = Change(B)
Print('Output is', C)

9. What will be the output of the following program:


def func (message , num = 1 ) :
print (message * num)
func ( 'Welcome ' )
func ( ' Viewers ' , 3)

10. What will be the output of the following program:


def func ( x = 1 , y = 2 ) :
x=x+y
y += 1
print (x , y )
func ( y = 2 , x = 1)

11. What will be the output of the following code?


def Changer(P,Q=10):
P=P/Q
Q=P%Q
Return P

A=200
B=20
A= Changer(A,B)
print(A,B,sep='$')
B= Changer(B)
print(A,B,sep='$',end=’###’)

12. What are the possible output(s) of the following program:


import random
PICK=random.randint (0 , 3 )
CITY=["DELHI" , "MUMBAI" , "CHENNAI" , "KOLKATA" ]
for I in CITY:
for J in range ( 1 ,PICK) :
print ( I , end=" " )
print ( )

13. Consider the following program, and predict the possible outputs:
import random
string="CBSEONLINE"
number=random. randint (0, 3)
N=9
while string [N] != 'L ' :
print (string [N]+ string [ number]+ '#' , end=' ' )
Page 3 of 4
number=number+1
N=N-1

a) ES#NE#IO# b) LE#NO#ON# c) NS#IE#LO# d) EC#NB#IS#

14. Consider the following program, and predict the possible outputs:
import random
print (100+random. randint ( 5 , 1 0 ) , end=' ' )
print (100+random. randint ( 5 , 1 0 ) , end=' ' )
print (100+random. randint ( 5 , 1 0 ) , end=' ' )
print (100+random. randint ( 5 , 1 0 ) )
a) 102 105 104 105 b) 110 103 104 105 c) 105 107 105 110 d)110 105 105 110

15. What possible output(s) is/are expected to be displayed on the screen at the time of
execution of the program from the following code ? Also specify the maximum and
minimum value that can be assigned to the variable R when K is assigned value as 2.
import random
Signal = [ 'Stop', 'Wait', 'Go' ]
for K in range(2, 0, 1):
R = randrange(K)
print (Signal[R], end = ' # ')
(a) Stop # Wait # Go # (b) Wait # Stop # (c) Go # Wait # (d) Go # Stop #

Page 4 of 4

You might also like