简体   繁体   English

Python-计算这个方程/表达式

[英]Python- Calculate this equation / expression

I have tried two different syntax's and when I ran the syntax's I got the mathmatical resolution in both attempts, but my quiz is wanting a specific line of code to get the result.我尝试了两种不同的语法,当我运行语法时,我在两次尝试中都得到了数学分辨率,但我的测验想要特定的代码行来获得结果。 Any idea how I'm SUPPOSED to get python to calculate this?知道我应该如何让 python 来计算这个吗? 在此处输入图片说明

在此处输入图片说明

This is not really a python problem and more a maths order of operations problem.这不是真正的 Python 问题,而是一个数学运算顺序问题。

In both examples you provide, you are adding the 1 after you divide (5**(1/2)/2) .在您提供的两个示例中,您在除以(5**(1/2)/2)之后添加1

You want this:你要这个:

ratio = (1 + 5**(1/2)) / 2

You should try this one.你应该试试这个。 It will help you understand the operator order better.它将帮助您更好地了解运营商的订单。

(1+(5**(0.5)))/2

Hope this helps希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM