Question: 5. Consider each of the following python loops. For each loop, answer: How many iterations does it do before halting? What are the last two

5. Consider each of the following python loops. For each loop, answer: How many iterations does it do before halting? What are the last two values of x it prints (both as decimals printed by python, and as IEEE standard 16-hex-digit representations)? Explain in one sentence what property of the floating-point system the loop's behavior demonstrates 5a. while 1.0+ x> 1.0 x = x 1 2.0 print (x) 5b. x = 1.0 while x + x > x x=2.0 * x print (x) 5c. x = 1.0 while x + x > x x=x/2.0 print (x)
Step by Step Solution
There are 3 Steps involved in it
To analyze each loop lets break them down step by step and consider IEEE floatingpoint behavior 5a python x 10 while 10 x 10 x x 20 printx Iterations ... View full answer
Get step-by-step solutions from verified subject matter experts
