Percent of change in Python

This program calculates the percent of change (or POC) between two numbers. So, all you have to do is, enter the old number, then the new number. Also, notice how we include two versions of the POC formula.

By the way, POC is also referred to as variance or difference. Most likely, variance is the term they use in financial firms.

Code listing to find percent of change in Python

Below is the code listing for this program.

# ----------------------------------------------------
# Designed and programmed by Alex Shaw III
# Date created:  January 5, 2023
# Last modified: January 5, 2023
# Calculates the percent of change between two numbers
# ----------------------------------------------------
print('\nCalculate percent of change\n' + '-'*27)       # display title
oldNum = input('Enter the old number: ')                # get old value
newNum = input('Enter the new number: ')                # get new value
#poc = (float(newNum) - float(oldNum)) / float(oldNum)  # long formula
poc = float(newNum) / float(oldNum) - 1                 # short formula
# Show results
print('\nThe percent of change for {0:.4g} to {1:.4g} is: {2:.5g}%\n'.
      format(float(oldNum), float(newNum), poc * 100))


Here is the output for the above program.

Percent of change in Python - Techronology

Developer’s note

Notice on line 16, we use the shorter version of the formula (New / Old – 1).

If you have any questions or comments, then send us an email at

Python page

Click on the button below to go to our Python page.

Python page

Create a menu in Python - Techronology

Python is a high-level computer programming language. If you want more information on Python, then visit Python Software Foundation.

Techronology home  Code library  Reference desk