Python program to calculate GST

In this article, we are going to calculate the GST (Goods and Services Tax) in Python. For calculating GST we need to understand that what is GST? What does GST stands for?

GST:- GST stands for Goods and Services Tax. It is a value-added tax on the goods and services which are sold for domestic purpose or consumption. The GST is paid by the customers to the government on purchasing goods and services. For example:-

  • Original price = Rs. 1000, Net price = Rs. 1180, GST% = 18%
  • Original price = Rs. 2500, Net price = Rs. 3000, GST% = 20%

How to calculate GST

To calculate the GST% first, we need to calculate the net GST amount by subtracting the Original price from Net price in which the GST is included. After Calculating the net GST amount, we will apply the GST% formula which is given below:-

GST% formula = ((GST Amount * 100)/Original price)

Net price = Original price + GST amount

GST amount = Net price – Original price

GST% = ((GST amount * 100)/Original price)

Program code to calculate the GST

  • Example 1
Original_price = 100
Net_price = 124.7
GST_amount = Net_price - Original_price

GST_percent = ((GST_amount * 100) / Original_price)
print("GST = ",end='') 


GST = 25%

In the above example, we used the formula which are provided above the code to calculate the GST%, and we used the round function to round the GST% to their nearest integer value.

  • Example 2
Original_price = 504
Net_price = 741.3
GST_amount = Net_price - Original_price

GST_percent = ((GST_amount * 100) / Original_price)
print("GST = ",end='') 


GST = 47.08333333333333%

In this example, we didn’t use the round function so the calculated GST% is in the form of a float number. So this is how we can calculate GST in Python.

Also learn:

Leave a Reply