You are on page 1of 2

Text1=”AISSCE 2023”

Text2=””
I=0
while I<len(Text1):
XII – CS – Functions Worksheet if Text1[I]>=”0” and Text1[I]<=”9”:
Val = int(Text1[I])
Val = Val + 1
Given Date:22/03/24 Submission Date:25/03/24 Text2=Text2 + str(Val)
elif Text1[I]>=”A” and Text1[I] <=”Z”:
1. Give the output Text2=Text2 + (Text1[I+1])
def Changer(P,Q=10): else:
P=P/Q Text2=Text2 + “*”
Q=P%Q I=I+1
print (P,”#”,Q) print (Text2)
return P 4. Give the output
A=200 Mystring=”What@OUTPUT!”
B=20 str=’’ ’’
A=Changer(A,B) for i in range(len(Mystring)):
print (A,”$”,B) if not Mystring[i].isalpha():
B=Changer(B) str=str+”*”
print (A,”$”,B) elif Mystring[i].isupper():
A=Changer(A) val=ord(Mystring[i])
print (A,”$”,B) val=val+1
2. Give the output str=str+chr(val)
def Findoutput(): else:
L=”earn” str=str+Mystring[i+1]
x=” “ print(str)
count=1 5. def Encode(Info,N):
for i in L: In=””
if i in[‘a’,’e’,’i’,’o’,’u’]: for I in range(len(Info)):
x=x+i.swapcase() if I%2==0:
else: v=ord(Info[I])
if count%2!=0: v=v-N
x=x+str(len(L[:count])) In=In+chr(v)
else: elif Info[I].islower():
count =count +1 In=In+Info[I].upper()
print (x) else:
Findoutput() v=ord(Info[I])
3. Find and write the output v=v+N
In=In+chr(v) (b) return statement is used inside a function
print(In) (c) Both (a) and (b)
Memo=”Justnow” (d) None of the above
Encode(Memo,2) 3. Zero or more keyword arguments can be passed to a function in a
6. Give the output (a) double function call (b) any function call
def func(x,y=2): (c) single function call (d) None of these
g=5 4. Which of the following function headers is correct?
x=x-y; (a) def myFunc(x = 2, y = 3, z):
g=g*10; (b) def myFunc(x = 2, y, z = 3):
print(x,y,g) (c) def myFunc(x, y = 2, z = 3):
g=7 (d) def myFunc(x, y, z = 3, p):
h=10 5. Which one of the following is the correct way of calling a function?
func(g,h) (a) function_name() (b) call function_name()
print(g,h) (c) ret function_name() (d) function function_name()
func(g) 6. Required arguments are the arguments passed to a function in
print(g,h) (a) any positional order (b) correct positional order
7. Give the output (c) odd positional order (d) even positional order
def repch(s): 7. What is the output of following code?
p=”” def test():
for i in range(len(s)-1): a=96
if i%2!=0 and s[i]==s[i+1]: print(a)
p=p+”@” a =+ 2
print(“Hello”) test()
elif s[i]= =s[i+1]: (a) 96 (b) 98 (c) 94 (d) Error
p=p+”!” 8. What will be the output of following code?
else: def test(i):
p=p+s[i] i = [3]
print(“Changed String”,p) num = [9]
str=”SUCCESS” test(num)
print(“Original String”,str) print(num)
repch(str) (a) [3] (b) [9] (c) [9, 3] (d) [3, 9]
MCQs 9. What is the output of following code?
1. Which is/are the advantage(s) of functions in Python? val=5
(a) Reducing duplication of code def test():
(b) Decomposing complex problems into simpler pieces global val
(c) Improving clarity of the code val=val+1
(d) All of the mentioned test()
2. None will return by function when print(val)
(a) return statement is not used inside a function (a) 6 (b) 5 (c) 4 (d) Error

You might also like