Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What would the code in wk4_p10.py do if the statement x = 25 were replaced by x = -25? What would have to be changed

image text in transcribed

What would the code in wk4_p10.py do if the statement x = 25 were replaced by x = -25?

What would have to be changed to make the code in wk4_p10.py work for finding an approximation to the cube root of both negative and positive numbers? (Hint: think about changing low to ensure that the answer lies within the region being searched.)

x = 25 epsilon = 0.01 numGuesses = 0 low = 0.0 high = max(1.0, x) ans = (high + low)/2.0 while abs(ans**2 - X) >= epsilon: print('low =', low, 'high =', high, 'ans =', ans) numGuesses += 1 if ans**2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

2nd Edition

1597499471, 978-1597499477

More Books

Students also viewed these Databases questions