Functions in Python - 241216 - 093710
Functions in Python - 241216 - 093710
December 3, 2024
return a+b
add(8,9)
[3]: 17
1
else:
print("number is odd")
a=int(input("enter any number"))
even_odd(a)
def factorial(number):
fact=1
while(number>0):
fact*=number
number-=1
print("the factorial of number is ",fact)
number=int(input("enter any number"))
factorial(number)
add=lambda x,y:x+y
x=int(input("enter the value of x "))
y=int(input("enter the value of y "))
print("the addition of x and y is ",add(x,y))
2
the addition of x and y is 12
[33]: # wap to print even numbers form the given list using lambda function
number=[432,2,432,12,343,23,4,55,66,5,67777,88,90989,87,787,678,876]
even=list(filter(lambda x:x%2==0,number))
print("the even numbers are :",even)
the even numbers are : [432, 2, 432, 12, 4, 66, 88, 678, 876]
[37]: # wap to print odd numbers form the given list using lambda function
number=[432,2,432,12,343,23,4,55,66,5,67777,88,90989,87,787,678,876]
odd=list(filter(lambda x:x%2!=0,number))
print("the odd numbers are :",odd)
the odd numbers are : [343, 23, 55, 5, 67777, 90989, 87, 787]
[ ]: