Find out the multiplication of two numbers in Python

Find out the multiplication of two numbers in Python :

In this tutorial, we will learn how to find out the multiplication of two numbers in python. The program will ask the user to enter the numbers and then it will calculate the multiplication of the numbers. Finally, it will print out the multiplication result.

Python program :

Below is the python program for the above problem :

#1
first_number = int(input("Enter your first number : "))
second_number = int(input("Enter your second number : "))

#2
final_result = first_number * second_number

#3
print("Multiplication of {} and {} is : {}".format(first_number,second_number,final_result))

Explanation :

The commented numbers in the above program denote the step numbers below :

1. Ask the user to enter the first and the second number. Read it and store it in first_number and second_number variables. Here, we are using input() method to take the user input. Also, we are converting the input to an integer using int() method.

If the user will enter anything else than an integer, e.g. a string, it will throw one ValueError

2. Next, find out the multiplication of these numbers. * is the multiplication operator in python.
3. Finally, print out the result to the user. Note how we are using the curly braces to print out the results.

Sample Output :

Enter your first number : 12
Enter your second number : 12
Multiplication of 12 and 12 is : 144

If anything other than an integer is entered :

Enter your first number : ff
Traceback (most recent call last):
  File "example.py", line 1, in 
    first_number = int(input("Enter your first number : "))
ValueError: invalid literal for int() with base 10: 'ff'

python find multiplication two numbers

Conclusion :

In this tutorial, we have learned how to find out the multiplication of two numbers in python. Try to run the above program on your machine and drop one comment below if you have any queries.

You might also like :

Leave a Reply