Python

Nicesnippets

21-06-2021

Hello Friends,

Now let's see example of how to substraction between two number in python. We will show python substraction two number example. i would like to share with you how to substraction two number in python. In this blog i will learn you how to substraction two variables in python.

Here i will give you substraction two numbers, the user is first asked to enter two numbers and the input is scanned using the input() function and stored in the variables number1 and number2. Then, the variables number1 and number2 are added using the arithmetic operator - and the result is stored in the variable substraction.

So let's see the bellow example:

**Example 1**

**sub.py**

# This program sub two numbers

number1 = 8

number2 = 5

# Substraction two numbers

total = number1 - number2

# Display the substraction

print('The substraction of {0} and {1} is {2}'.format(number1, number2, total))

**Output :**

The substraction of 8 and 5 is 3

**Example 2**

**sub.py**

# Store input numbers

number1 = input('Enter first number: ')

number2 = input('Enter second number: ')

# Substraction two numbers

total = float(number1) - float(number2)

# Display the sub

print('The substraction of {0} and {1} is {2}'.format(number1, number2, total))

**Output :**

Enter first number: 8.3

Enter second number: 2.1

The substraction of 8.3 and 2.1 is 6.2

**Run python file:**

python sub.py

It will help you....

- React js File Upload Example With Axios
- How to Get Current URL in Laravel?
- How to upload file using ckeditor in php?
- CodeIgniter 4 - Export Data to Excel in Using PHPexcel Example
- How to get current route name path and action in laravel 6 ?
- How To Send Mail Markdown Table Foreach In Laravel?
- How To Add Hours To The Current Time In Python?
- Reactjs Pure Component With Example
- Installation of the Vivaldi Browser in Ubuntu 22.04 Example
- How to Get Value of Textbox in JavaScript