簡體   English   中英

相當於 Python 或 MYSQL 中的 Excel Goal Seek 函數

[英]equivalent of Excel Goal Seek function in Python or MYSQL

我將如何使用 Python 或 mysql 實現Excel Goal Seek函數?

這是場景:

在我工作的代理機構中,他們購買商品然后賣到網上商店,這家網上商店適用 3 種不同的費用,根據最終價格計算。 該機構希望以最終價格賺取固定金額,因此我需要用費用和他們想要賺取的金額來計算最終價格。

我知道他們想要賺取的金額和初始價格,以及以 % 為單位的費用,我不知道我需要以什么價格出售這些物品才能賺取特定數量的錢。

使用excel,他們使用目標搜索功能來計算最終價格以及所有費用和代理商想要賺取的固定金額,我想用python或mysql來做。

例如:

a1 = 270.0$ # This is the price they buy the item
c2 = 3.50$ # This is the shipping Price
c3 = 0.10 # This is the FEE of the store in percentage (10%)
c4 = 0.03 # This is the FEE for the credit card (0.3%)
c5 = 0.35$ # This is the Fixed FEE for the store 0.35$
d1 = 5$ # This is the amount they want to earn when they sell the item
x = ? # This is the final price they need to sell the item for earn d1

謝謝你的幫助

在 Python 中,您可以執行以下操作。 注意公式可能需要調整

a1 = 270.00  # This is the price they buy the item in $

c2 = 3.50  # This is the shipping Price in $
c3 = 0.10  # This is the FEE of the store in percentage (10%)
c4 = 0.03  # This is the FEE for the credit card (0.3%)
c5 = 0.35  # This is the Fixed FEE for the store $0.35

d1 = 5.00  # This is the amount they want to earn when they sell the item in $
x = 0.00  # This is the final price they need to sell the item for earn d1

while True:
    # Assumed Formula - this may need to be adjusted to match your criteria
    earnt_amount = ((x - a1 - c2) * (1 - c3 - c4)) - c5
    x += 0.01
    if earnt_amount >= d1:
        break

print ('Price "x" should be: {0}'.format(x))

這是Python中Excel的等效目標。 請查看“ ExampleScript.py”以了解其工作方式。 鏈接: https//github.com/DrTol/GoalSeek_Python

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM