Python Forum

Full Version: Profit on Pricing Solver
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Finally created this program for the "Pricing Calculations" solver.
This Profit for Pricing solver ask for any two knowns values and program
will solve for the remaining two values from Cost, Price, Markup and Margin.

User enter 0 (zero) for the two unknowns values

Program will ask for four values in this order:

Cost -> Price -> Markup -> Margin -> display answer with profit amount.

print("==========================================")
print("  Profit on Pricing Calculator")
print("  Enter Zero for the Two Unknown Valiables")
print("==========================================")
print("   Cost -> Price -> Markup -> Margin      ")
print("==========================================")

CST = float(input("Enter Cost  : "))
SEL = float(input("Enter Price : "))
MUP = float(input("Enter Markup: "))
MAR = float(input("Enter Margin: "))

p = 100 # constant used for percentage

if CST and SEL != 0: # if both true
   MAR = float(p * ((SEL - CST) / SEL))
   MUP = float(p * ((SEL - CST) / CST))

if MAR == 0: # if true compute Margin
   MAR = float(MUP / (1 + (MUP / p)))
   
# constant to plug into remaining formulas
q = 1 - (MAR / p)
   
if MUP == 0: # if true compute Markup
   MUP = float(MAR / q)

if CST == 0: # if true compute Cost
   CST = float(SEL * q)
   
if SEL == 0: # if true compute Price
   SEL = float(CST / q)

print("==================")        
print("Cost   = ", "%1.2f"%(CST))
print("Price  = ", "%1.2f"%(SEL))
print("Markup = ", "%1.1f"%(MUP), "%")
print("Margin = ", "%1.1f"%(MAR), "%")
print("==================")
print("Profit = ", "%1.2f"%(SEL - CST))
print("==========================================")
Here is a quick look with this program:
https://trinket.io/python3/7b7ef02082?outputOnly=true

Remark:
This program can also calculate just between Markup and Margin.
Cost = 0, Price = 0 and input value either one of the Markup or Margin.

I try to use this program to create GUI by Tkinter but not successful yet.

Gamo 7/2020