Question: Python While loop error Consider the following code: n = 10 i = 10 while i > 0: print i if i % 2 -

Python While loop error

Python While loop error Consider the following code: n = 10 i

Consider the following code: n = 10 i = 10 while i > 0: print i if i % 2 - 0: i = i/2 else: i = i + 1 First, what is your best guess as to what this code is trying to do? Keep in mind, there are errors in this code, and there is no "right" answer as to its intent. Try running the code to see what happens. Once you've decided what you feel is the goal of this code, share your thoughts on this while pointing out any errors. Correct the code based on your interpretation. Share your revised code, including comments within your code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!