In this article, we will discuss the concept of the Subtract two numbers in Python programming
In this post, we are going to learn how to write a program find the subtraction of two numbers in Python programming language
The program used to find the subtraction of given two numbers
Program 1
#Python program to subtract two numbers num1=56.8; #variable declaration and initialization num2=67.9; #Subtract two numbers sub=num2-num1; #display the result of substraction print("The subtract of {0} and {1} is {2}".format(num2,num1,sub) )
When the above code is executed , it produces the following result
The subtract of 67.9 and 56.8 is 11.1
This program allows the user to enter two numbers Then the program find the subtraction of the given two number
Program 2
#Python program to subtract two numbers #stare the input numbers num1=input("Enter the first number: "); num2=input("Enter the second number: "); #Subtract two numbers sub=float(num2)-float(num1); #display the substract print("The subtract of {0} and {1} is {2}".format(num2,num1,sub) )
When the above code is executed , it produces the following result
Case 1
Enter the first number: 5.8 Enter the second number:9.8 The subtract of 9.8 and 5.8 is 4.0
case 2
Enter the first number: 7.8 Enter the second number: 5.3 The subtract of 5.3 and 7.8 is -2.5
Suggetsed for you
Introduction of Python language
Similar post
Sum of two number in Python using function
Sum of two number in Python using recursion
Calculate the sum of natural numbers in Python
Calculate the sum of natural numbers in Pyton using recursion
Calculate sum of odd and even number in Python language
Calculate sum of odd and even number of the list in Python language
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…
View Comments
WOW, I just read this article and found it very useful and informative.