problem – Python program to multiply two numbers without using arithmetic operator
In this tutorial, we will discuss the concept of multiplying two numbers without using arithmetic operator in Python language.
In this post, we will learn how to get the product of two number without arithmetic operator in Python programming language
This program is used to find the multiplication of two numbers entered by the user – using for loop without arithmetic operator
#How to print product of two numbers without using "*" operator in Python num1=int(input("Enter a number for num1: "))#get input from user for num1 num2=int(input("Enter a number for num2: "))#get input from user for num2 product=0 for i in range (1,num2+1): #Python for loop product=product+num1 #product+=num1 print("Multiplication of numbers: ",product) #Display multiplication of numbers
When the above code is executed, it produces the following result
Enter a number for num1: 25 Enter a number for num2: 50 Multiplication of numbers: 1250
Using function – Program 2
This program is used to find the multiplication of two numbers entered by the user – using if elif statements without arithmetic operator
x=int(input("Enter a number for x: "))#get input from user for x y=int(input("Enter a number for y: "))#get input from user for y def findProduct(x,y): #Python function if y<0: return -findProduct(x,-y) elif y == 0: return 0 elif y == 1: return x else: return x+ findProduct(x,y-1) print("product of two numbers: ",findProduct(x,y)) #Display result on the screen
When the above code is executed, it produces the following result
Enter a number for x: 30 Enter a number for y: 12 product of two numbers: 360
Similar post
C program to multiply two numbers without using arithmetic operator
C++ program to multiply two numbers without using arithmetic operator
Java program to multiply two numbers without using arithmetic operator
Multiply two numbers in Python
Java program to Multiply two numbers
Python program to multiply two numbers without using arithmetic operator
C++ find product of two numbers
Python program to multiply two numbers using function
C code to multiply two numbers using function
C# program to multiply two numbers using function
PHP program to multiply two numbers
C# program to multiply two numbers
JavaScript program to multiply two numbers
Suggested for you
Operators in Python programming language
For loop in Python programming language
Data type in Python programming language
If elif statements in Python programming language
10 simple ways to add two numbers in Java In this article, we will discuss…
Write a Python program to find the first n prime numbers In this article we…
Python: Calculate Average of odd and even in a list using loops In this post,…
Python: Average of Odd & Even Numbers from User Input In this post, we will…
Explanation of one dimensional array In this post, we will discuss the concept of "Explanation…
Python program to calculate the sum of odd and even numbers in a list In…