
#原题目在运行截图中 |
import math |
def f(x): |
y = (2**x) + (3*x) - 7 |
return y |
a = float(input("a=")) |
b = float(input("b=")) |
ε = float(input("ε=")) |
while math.fabs(a-b) >= ε: |
c = (a+b)/2 |
if (f(a)*f(c)) < 0: |
b = c |
|
else: |
if f(c) == 0: |
a = c |
break |
else: |
a = c |
print("x=",a) |



