Function-WS-01
Function-WS-01
def check(n1=1,n2=2):
n1=n1+n2
n2+=1
print(n1,n2)
check()
check(2,1)
check(3)
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)
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)
x=5
def func2():
global x
x=x+1
print (x)
func2()
print (x)
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]
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.