Search

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

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: "))

sub(x,y)

mul(x,y)

div(x,y)

Output:

Enter first numbers: 5

Enter Second numbers: 8

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

19 views

### Recent Posts

See All

#### Python program to print sum of n natural numbers

a=int(input("Enter a number: ")) sum = 0 while(a > 0): sum=sum+a a=a-1 print("The sum of natural numbers is",sum)

#### Python Programs to print pattern Number, Pyramid, Star, Diamond and Letter Pattern

Write a python program for given Numbers Pattern using a for loop 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 Program: for num in range(6): for i in range(num): print(num, end=" ") print(" ") Write Python Program f

#### Python Program for Cube of a Number using Functions

Program: def cube(a): print("The Cube of given number", a*a*a) b = int(input(" Enter any number : ")) cube(b) Output: Please Enter any numeric Value : 5 The Cube of a Given Number 5 = 125

9555593818