CP104 Lecture 21: Cp104 lesson 21

17 views2 pages
School
Course
hayjayshay and 38575 others unlocked
CP104 Full Course Notes
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:

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents