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

Function-WS-01

Uploaded by

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

Function-WS-01

Uploaded by

damianwayne69420
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Class-12

Chapter: User defined Function


Class Work
__________________________________________________________________
1. Find the output of the following snippets:

def check(n1=1,n2=2):
n1=n1+n2
n2+=1
print(n1,n2)
check()
check(2,1)
check(3)

2. Find the output of the following snippets:

def change(p,q=30):
p=p+q
q=p-q
print(p,"#",q)
return (p)

R=150
S=100
R=change(R,S)
print(R,"#",S)

3. Find the output of the following snippets:

def add(x,y,z):
print(x+y+z)
def prod(x,y,z):
return(x*y*z)

a=add(6,16,26)
b=prod(2,3,6)
print(a,b)

4. Find the output of the following snippets:

x=5
def func2():
global x
x=x+1
print (x)
func2()
print (x)

5. Find the difference between following:


(a) global and local scope.
(b) default and keyword arguments.

6. Write a Python code to accept a string from the user. Pass the string to a function def
Display(s) which displays consonants present in the string.

Input: computer

Output:
c
m
p
t
r

7. Write a program to take input of two lists from user and find the union and intersection of the
two list using functions.
Example:
Input:
l1= [1,2,3,4,5,6]
l2= [5,6,7,8]

Output:
union:[1,2,3,4,5,6,7,8]
Intersection:[5,6]

8. Change brought in immutable parameter does not reflect on the _________.

9. The values passed to function body are referred to as the ___________,whereas, the values
being received as the ______________.

10. ___________ value is directly assigned to the parameter by using equal to (=) sign.

You might also like