This is not really a python problem and more a maths order of operations problem.
In both examples you provide, you are adding the 1
after you divide (5**(1/2)/2)
.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.