top of page
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

## Recent Posts

See All

Write a Python function to calculate the factorial of a number (a non-negative integer). The function accepts the number as an argument. This program is most for O Level Practical Exam so read it care

This program is most for O Level practical Exam so read it carefully. Write a Python program that accepts a hyphen-separated sequence of words as input and prints the words in a hyphen-separated seque

This program is most for O Level Practical Exam so read it carefully. Program: import numpy as np x = np.array([1,2,3,4,5,7,2,1,1,1,8,9,1]) print(x) print("most frequent value in the list:") print(np.

bottom of page