繁体   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