iteration

Cards (13)

  • What is a condition controlled iteration used for?
    When the number of repetitions is unknown
  • How does a condition controlled iteration terminate?
    When a condition becomes True or False
  • What type of loop is used for condition controlled iteration?
    While loop
  • What does the while loop check after setting tfAnswer to True?
    If tfAnswer is still False
  • What is a count controlled iteration used for?
    When the number of repetitions is known
  • What type of loop is used for count controlled iteration?
    For loop
  • What does the range function control in count controlled loops?
    The number of iterations
  • What does the range function start counting from in Python?
    0
  • What does the range function do when given three parameters?
    Controls starting point and increment value
  • What is printed when using range(1,10,2)?
    1, 3, 5, 7, 9
  • What are the key differences between condition controlled and count controlled iterations?
    • Condition Controlled:
    • Unknown repetitions
    • Uses while loop
    • Count Controlled:
    • Known repetitions
    • Uses for loop
  • What are the roles of the counter variable in condition controlled iterations?
    • Tracks the number of iterations
    • Triggers condition change when reaching a limit
    • Determines when to exit the loop
  • What are the parameters of the range function in Python?
    • Start point (default is 0)
    • Stop point (exclusive)
    • Step value (default is 1)