top of page
Writer's pictureRajesh Singh

Python Program using function to calculate addition, substraction, multiplication and division



def add(a,b):

print("Addition of two numbers", a+b)

def sub(a,b):

print("Subtraction of Two numbers",a-b)

def mul(a,b):

print("Multiplication of two numbers", a*b)

def div(a,b):

print("Division of two numbers",a/b)

x=int(input("Enter first numbers: "))

y=int(input("Enter Second numbers: "))

add(x,y)

sub(x,y)

mul(x,y)

div(x,y)

Output:

Enter first numbers: 5

Enter Second numbers: 8

Addition of two numbers 13

Subtraction of Two numbers -3

Multiplication of two numbers 40

Division of two numbers 0.625


To check even or odd number using function

def even(a):

if a%2==0:

print("Number is even")

else:

print("Number is odd")

x=int(input("Enter a Number: "))

even(x)

Output:

Enter a Number: 12

Number is even

1,789 views0 comments

Recent Posts

See All

Comments


bottom of page