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

Worksheet Function Answer Key

.......mm.jjkkvff

Uploaded by

kabir082020kscs
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)
51 views

Worksheet Function Answer Key

.......mm.jjkkvff

Uploaded by

kabir082020kscs
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/ 8

VELAMMAL BODHICAMPUS, THANJAVUR

Teacher Capy
GRADE: XIL SUB: COMPUTER SCIENCE

WORKSHEET (01)-FUNCTIONS DATE :11.12.2024


1 Function name must be followed by
Ans
2 keywordisusedtodefineafunction
Ans
3 Function will perform its action only when it is
Ans Celecdl iVokeel
Writestatementtocallthefunction.
defAdd():
X=10+20
print(X)
Addt #statementtocalltheabovefunction
Ans
Writestatementtocallthefunction.
defAdd(QX,Y):
Z-X+Y
print(Z)
Adoib,0#statement to call the above function
Ans
6 Writestatementtocallthefunction.

defAdd(X,Y):
Z=X+Y
returnZ
#statement to call the above function
print("Total =",C)
Ans
WhichLineNumberCodewillnever execute?
def Check(num): #Line 1
if num%2==0: #Line 2
print("Hello") #Line 3
returnTrue #Line4
print("Bye") #LineS
else: #Line6
return False #Line7
C= Check(20)
print(C)
Ans
Whatwillbetheoutputoffollowingcode?
defCube(n):
print(n*n*n)

Cube(n) #n is 10 here
print(Cubc(n))
Ans

cxample of any
9 What arc the different types of actual arguments in function? Give
one of them.
Ans

10 Whatwillbetheoutputoffollowingcode:
defAlter(x,y=10,z-20):
sum-xty+z
print(sum)
Alter(10,20,30)
Alter(20,30)
Alter(100)

AnsbO

130 he has to
11
working on a project, for some requirement,
Ravia python programner isCalculatelnterest(), he defined it as:
define a function with name
def CalculateInterest(Principal,Rate.06,Time);
#code
Butthiscodeisnotworking, CanyouhelpRavitoidentifytheerrorintheabove function
and what is the solution.

Ans
12 CallthegivenfunctionusingkEYWORDARGUMENTwithvalues100and 200
def Swap(num l,num2):
numl,num2num2,nunl
print(num1,num2)

Swap(ýLLMls Bwm=20oo
Ans

13 Whichlinenumber ofcode(s)willnotworkandwhy?
def lnterest(P,R,T=7):
I-P*R*TY100
print([)

Interest(20000,.08,15)
Interest(T=10,20000,.075)
#Linel
#Line2 ’ ka must not oll pest
Interest(50000,.07) #Line3
#Line4 no nme
Interest(P=10000,R=.06,Time=8)
Interest(80000,T=10)
Ans

14 Whatwillbetheoutputoffollowingcode?
defCalculate(A,B,C):
returnA*2,B*2,C*2
val = Calculate(1 0,12,14)
print(type(val))
print(val)
Ans elos
15 Write the term suitable for the following descriptions:
(a) Aname inside the parentheses of a function header that can receive a
value. Psomele keyeeac
(b) Anargument passed to a specific parameter using the parameter name.t
(c) Avalue passed to a function parameter. Aagument
parameter name in the function call.h O
(d)Avalue assigned to a
(e) A name defined outside all function definitions. Gilobal
koA variable created inside a function body. hocal

3
16
What wil betheoutputofollowingcode?
defcheck():
num=50
print(numn)
num=100
print(num)
check)
print(mum)
Ans

17 (Consider the following code and write the flow of


numbers have been given for our reference. execution for this. Line
1.defpower (b, p):
2. y = b ** p
3.return y
4.
5.defcalcSquare(x):
6. a =power (x, 2)
7. return a
8.
9. n =5
10. result =calcSquare (n)
11. print (result)
Ans

18 Whatwillbetheoutputoffollowingcode?
print(*"Welcome!")
print("Iam: name) # isdoubleunderscore
Ans

19 FunctioncanalteronlyMutabledatatypes?(True/False)
Ans
20 AFunctioncancallanotherfunctionoritself?(True/False)
Ans
Whatwillbetheoutputoffollowingcode?
21
defdisplay(s):
|= len(s)
foriinrange(0,1):
ifs[i].isupper):
m=mts[i).lower()
clifs(i].isalpha(): Exam$g*CRSE*COM
m=mts[i].upper()
elifs[i].isdigit():
m=m+"$"
else:

print(m)
display("[email protected]")
Ans
22 Whatwillbetheoutputoffollowingcode?

defAlter(M,N=S0):
M=M+N
N=M-N
print(M"@",N)
retum M

A=200
B=100
A=Alter(A,B)
print(A,"#"B)
B= Alter(B)
print(A,"@"B)
Ans
PSO@ too
Bo0
23
Whatwillbetheoutputoffollowingcode?
defTotal(Number=10):
Sum-0
for C in range(1,Number+l ):
if C%2-0:
continue
Sum+=C
returnSum

print(Total(4))
print(Total(7))
print(Total())
Ans

24 Whatwillbetheoutputoffollowingcode?
X=100
defChange(P=10,Q=25):
global X
ifP%6=0:
X+-100
else:
Xt=50
Sum-P+Q+X
print(P,'#",Q,S,Sum)
Cbange)
Change(18,50)
Change(30,100)
Ans

25 Whatwillbetheoutputoffollowingcode?
a=100
defshow):
globala
a=200

definvoke):
globala
a=500
show)
invoke)
print(a)
Ans
26 Whatwillbetheoutputoffollowingcode?
def drawline(char-"S",time-5):
print(char*time)
drawline)
drawline(@,10)
drawline(65)
drawline(chr(65))
Ans

A AAAA
27 Whatwillbetheoutputoffollowingcode?
defUpdater(A,B=s):
A=A//B
B-A%B
print(A, 'S,B)
returnA+B

A=100
B=30
A=Updater(A,B)
print(A,#,B)
B=Updater(B)
print(A,#,B)
A=Updater(A)
print(A,"S".B)
Ans
|3$3

28 Whatwillbetheoutputoffollowingcode?
defFunl (num1):
num]*=2
numl Fun2(numl)
return num1

defFun2(num 1):
num1=num1//2
return num1

n=120
n=Funl(n)
print(n)
Ans
|20
29 Whatwillbetheoutputoffollowingcode?
X=50

defAlpha(num 1):
global X
numl t= X
X += 20
numlBeta(num1) retun
num1

defBeta(num1 ):
global X
num] t= X
X += 10
num1=Gamma(num1)
returm num1

def Gamma(numl):
X= 200
numl +=X
retumn num]

num=100
num-Alpha(num)
print(num,X)
Ans
those place names
30 Write a method COUNTNOW(PLACES) to find and display
storing the name of places in a
in which there are more than 5 characters after Contains:
dictionary. For example, if the dictionary PLACES
"NEW YORK", '5': "DUBA"
k'1': "DELHI", 2: "LONDON", '3: "PARIS", '4':
The following output should be displayed:
LONDON
NEW YORK

Ans
places :'Delhi
dof Cowntncwl place):
tor i in places'yalal):
PAint (pal.bpes )
Countnoot paces)

You might also like