gpt4 book ai didi

python - 相当于 Python 或 MYSQL 中的 Excel Goal Seek 函数

转载 作者:行者123 更新时间:2023-12-01 00:39:24 25 4
gpt4 key购买 nike

我将如何实现 Excel Goal Seek使用 Python 或 mysql 运行?

这是场景:

在我工作的代理商中,他们购买商品然后卖给在线商店,这家在线商店收取 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 - 相当于 Python 或 MYSQL 中的 Excel Goal Seek 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37430361/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com