0% found this document useful (0 votes)
65 views2 pages

Worksheet On Functions

The document is a Grade 12 functions worksheet that includes various programming exercises related to defining and calling functions in Python. It covers topics such as function parameters, return values, local and global variables, and expected outputs for given code snippets. Additionally, it poses questions about errors in function definitions and requires students to analyze code execution flow.

Uploaded by

monibas27
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views2 pages

Worksheet On Functions

The document is a Grade 12 functions worksheet that includes various programming exercises related to defining and calling functions in Python. It covers topics such as function parameters, return values, local and global variables, and expected outputs for given code snippets. Additionally, it poses questions about errors in function definitions and requires students to analyze code execution flow.

Uploaded by

monibas27
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Grade 12 Functions Worksheet Date : 30.04.

2025

1. Function name must be followed by


2. Function will perform its action only when it is
3. Write statement to call the function.
def Add():
X = 10 + 20
print(X)
#statement to call the above function
[Link] statement to call the function.
def Add(X,Y):
Z = X+Y
print(Z)
#statement to call the above function
5. Write statement to call the function.

def Add(X,Y):
Z = X+Y
return Z
#statement to call the above function print(“Total =”,C)
6. Which Line Number Code will never execute?
def Check(num): #Line 1 if num
%2==0: #Line 2
print("Hello") #Line 3
return True #Line 4
print("Bye") #Line 5
else: #Line 6
return False #Line 7 C =
Check(20)
print(C)
7. What will be the output of following code?
def Cube(n):
print(n*n*n)
Cube(n) # n is 10 here print(Cube(n))
8. What will be the output of following code:
def Alter(x, y = 10, z=20): sum=x+y+z
print(sum)
Alter(10,20,30)
Alter(20,30) Alter(100)
9. Ravi a python programmer is working on a project, for some requirement, he has to define a function
with name CalculateInterest(), he defined it as:
def CalculateInterest(Principal,Rate=.06,Time): # code
But this code is not working, Can you help Ravi to identify the error in the above function and what is the
solution.
[Link] the given function using KEYWORD ARGUMENT with values 100 and 200
def Swap(num1,num2): num1,num2=num2,num1
print(num1,num2)
Swap( , )
11. Which line number of code(s) will not work and why?
def Interest(P,R,T=7):
I = (P*R*T)/100
print(I)

Interest(20000,.08,15) #Line 1
Interest(T=10,20000,.075) #Line 2
Interest(50000,.07) #Line 3
Interest(P=10000,R=.06,Time=8) #Line 4
Interest(80000,T=10) #Line 5
What is Local Variable and Global Variables? Illustrate with example
12. What will be the output of following code?
def display(s):
l = len(s)
m=""
for i in range(0,l):
if s[i].isupper():
m=m+s[i].lower()
elif s[i].isalpha():
m=m+s[i].upper()
elif s[i].isdigit():
m=m+"$"
else:
m=m+"*"
print(m)
display("EXAM20@[Link]")
13. What will be the output of following code?

def Total(Number=10):
Sum=0
for C in range(1,Number+1): if C
%2==0:
continue Sum+=C
return Sum
print(Total(4))
print(Total(7))
print(Total())

14. What will be the output of following code?


X = 100
def Change(P=10, Q=25): global X
if P%6==0:
X+=100
else:
X+=50 Sum=P+Q+X
print(P,'#',Q,'$',Sum) Change()
Change(18,50)
Change(30,100)

You might also like