In python Some tasks are best handled by \"definite iteration\" (a for loop), bu
ID: 3847005 • Letter: I
Question
In python
Some tasks are best handled by "definite iteration" (a for loop), but "indefinite iteration" (a while loop) is better for others. For each task below specify which type of iteration is best Write "for" or while in each case: Summing the first n values in a list. Summing the values in a list up to, but not including the first value that is less than 0 Printing all of the values in a list in order. Finding the average of values entered by a user until the user enters the string "quit". Finding the value of n at which the ratio, fibonacci (n)/fibonacci (n-1), is within 1.0e-10 of the golden ratio. [Remember Labo3.]Explanation / Answer
Solution:
a. "definite iteration" (a for loop ) is best suited here.
Explanation:
b. "indefinite iteration" (a while loop) is best suited here.
Explanation:
c. "definite iteration" (a for loop) is best suited.
Explanation:
d. "indefinite iteration"(a while loop) is best suited
Example:
e. "indefinite iteration"(a while loop) is best suited
Explanation:
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.