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
Suggested for you
If elif statements in Python
C# inverted full pyramid star pattern In this article, we will discuss the concept of…
C# Full Pyramid star pattern program In this article, we will discuss the concept of…
Program to count vowels, consonants, words, characters and space in Java In this article, we…
How to print multiplication table using Array in C++ language In this post, we will…
C Program to multiplication table using Array In this tutorial , we will discuss about…
Java program to check odd or even using recursion In this tutorial, we discuss a…