Calculations

Python Example to subtract two integer without using minus operator

Python Example to subtract two integer without using minus operator

In this article, we will discuss the concept of the Python Example to subtract two integer without using minus operator

In this post, we are going to learn how to  write a program to find the subtraction of two numbers with out using minus operator in Python programming language

subtract two integer without minus

Code to find the subtraction of  two numbers 

Subtract two integer using without minus

The program use to calculate subtraction of given two integer numbers using without minus operator in Python language

Program 1

num1=200#variable declaration
num2=75
sub=num1+(~num2+1)
#calculate subtraction without minus
print('The subtraction of {0} and {1} is: {2}'.format(num1, num2, sub))
#display output

When the above code is executed, it produces the following result

The subtraction of 200 and 75 is: 125

 

Subtract two integer using without minus – takes user input

Program 2

The program allow the user to enter two numbers and then calculates subtraction of given two integer numbers using without minus operator in Python language

num1=int(input("Enter first number: "))
num2=int(input("Enter second number: "))
#ask input from the user
#two input are stored in variable num1,num2 respectively
sub=num1+(~num2+1)
#calculate subtraction using without minus
print('The subtraction of {0} and {1} is: {2}'.format(num1, num2, sub))
#display output on the screen

When the above code is executed, it produces the following result

case 1

Enter first number: 1000
Enter second number: 400
The subtraction of 1000 and 400 is: 600

 

Case 2

Enter first number: 400
Enter second number: 1000
The subtraction of 400 and 1000 is: -600

 

Suggested for you

Operator in Python language

Data type in python language

if statements in Python language

function in Python language

 

Similar post

Subtract two numbers in Java language

Subtract two numbers using method in Java language

Subtract two numbers using recursion in Java language

Find sum of two numbers in Java

Find sum of two numbers in Java using recursion

Find sum of two numbers in Java without Arithmetic operator

Find sum of natural numbers in Java language

Find sum of natural numbers in Java language using recursion

Java Example to subtract two integer without using minus operator
C Example to subtract two integer without using minus operator
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

How to find reverse number using method in Java

How to find reverse number using method In this article, we will discuss the concept…

2 days ago

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

3 weeks ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

1 month ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

1 month ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

1 month ago

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

2 months ago