CP104 Lecture 21: Cp104 lesson 21
hayjayshay and 38575 others unlocked
2
CP104 Full Course Notes
Verified Note
2 documents
Document Summary
Temp = int(input( enter temperature (__ to quit): )) While temp !=___: total = total + temp, count = count + 1, temp = int(input( enter temperature (__ to quit): )) Infinite loops repeat and do not stop until the program is externally interrupted. Causes: 1) the programmer forgets to change the loop condition variable(s) o 2) the programmer changes the loop condition variable(s) incorrectly o 3) the condition is incorrectly written, 4) the loop lacks an actual test condition. Python has a boolean type with two values: o true, false. Ex. grade = int(input( enter final grade: )) Passed = grade >= 50 #doing this is probably clearer than doing if grade >= 50: If passes == true: print( you passed the course! ) condition controlled loopevent driven. # ask a user to guess a secret number. While not_found == true: guess = int(input( guess a number: )) o if guess == secret_number: