Computer Science 1026A/B Chapter Notes - Chapter 4: Saber Of London, Sentinel-2, Empty String
terubarenuka and 39895 others unlocked
26
COMPSCI 1026A/B Full Course Notes
Verified Note
26 documents
Document Summary
Executes instructions repeatedly until goal is reached. Flow of execution loops again to the point where condition is tested. Keeps getting tested until goal is reached. While balance < target: while statement. Interest =balance * rate / 100 body of while statement. Aka while means as long as condition is true. Infinite loop if condition never becomes false: kill a hanging system by ctrl + c, don"t forget to update variable in the while statement. Update variable inside loop: something inside the loop should change one of the variables used in the test. Count controlled bc controlled by counter: counter = 1, while counter <= 10 , print(counter, counter = counter + 1. Event-controlled bc executes until an event occurs: while balance < target , year = year + 1, balance = balance + interest interest = balance * rate / 100. Definite if you know how many iterations it takes to reach goal.