INFO1110 Lecture Notes - Lecture 4: Negative Number, Order Of Merit

13 views1 pages

Document Summary

When writing while loops for counting, keep 3 things in mind: initialise a counter variable, update the counter variable, ensure there is a stopping condition i = 0 while i < 5: print(i) i = i + 1. You can force exit a loop by using break you can force a reiteration (go back to start) with continue. How to end a loop: ask before iterating: ask the user if it is time to end the loop. A user can end a loop by entering a sentinel value. For example, enter all test scores followed by negative number: using break and continue keywords. Using break and continue can add complexity and should be avoided, if possible. A owchart can be used to easily convey the control ow and execution paths of a program: boxes represent code statements, diamonds represent conditions, i. e. decision points. If a diamond does not have an arrow going back to it, it"s an if statement.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents