ECS 32A Lecture 11: While Loops

49 views2 pages
Verified Note

Document Summary

Indents are typically 4 spaces or press the tab key. Each line of code should not be more than 80 characters long. My_string = ( this is a very long string . For list and dictionaries, indent after each item. Loops consist of two components: condition and body. Each time the loop body is called is called an iteration. If loops conditions is never satisfied, this would be an infinite loop. The most common case where we have while loops is when we wait for inputs. When you want to collect a quantity or values in a while loop, create the variable before you enter the loop. We can break infinite loops with a break statement. Skips the rest of the loop iteration, goes right back up top and checks the condition. While true: #infinite loop declaration deci = int(intput( enter a 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