Multiplication of Two Numbers in Python

(Last Updated On: 09/11/2022)

In this python program example, we use two methods to multiply two numbers 1st is a simple method, and 2nd is using a user-defined function.

Python Program to Multiply Two Numbers

# Multiplication of Two Numbers in Python

# we are taking a number from user as input
# entered value will be converted to int from string
num1 = int(input("Enter the First Number: "))
num2 = int(input("Enter the Second Number: "))

output = num1 * num2

#display the Multiplication
print("Multiplication of Two Numbers using integer",output)

Output:

Enter the First Number: 15
Enter the Second Number: 9
Multiplication of Two Numbers using integer 135

Python Program to Multiply Two Numbers Using Function

# Multiplication of Two Numbers in Python

 # defined a function multiplication to multiply two numbers
def multiplication(x, y):
	z = x * y
	return z

# we are taking a number from user as input
# entered value will be converted to int from string
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))

result = multiplication(a, b)
print("Multiplication of two numbers:", result)

Output:

Enter first number: 12
Enter second number: 8
Multiplication of two numbers: 96

Leave a Reply

Your email address will not be published. Required fields are marked *