- If you change between 1 and 20 from the previous program to between 1 and 6000, how many guesses will you need to guarantee that you have the right answer? Explain.
You will need 6000 guesses to be guaranteed that you have the right answer because there are 6000 integers in the range from 1-6000. Thus, you need one guess for each integer.
- Describe the difference between a while loop and a for loop.
The for statement iterates through a collection of values, whereas the while statement loops through until a condition is False.
No comments:
Post a Comment