Home
Browse
Create
Search
Log in
Sign up
Upgrade to remove ads
Only $2.99/month
Python ch 4.2- Loops
STUDY
Flashcards
Learn
Write
Spell
Test
PLAY
Match
Gravity
Terms in this set (22)
What are loops used for?
to repeat code as long as a condition is true
What are the four types of loops?
for loops, for each loops, while loops, nested loops
Which loop do we use to go through a string(word)?
for each
Which loop has a loop within a loop?
nested loop
What type of loop is the following?
for x in range(3):
print "Hi"
for loop
What type of loop is the following?
for x in range(2,3):
print "Hi"
for loop
What type of loop is the following?
for x in "hello":
print x
for each
What type of loop is the following?
x = 2
while x <7:
print "Hi"
x = x+1
while loop
What type of loop is the following?
for x in range(3):
print "x is", x
for y in range(2):
print "y is", y
print
nested loop
In the following loop the control variable starts x starts at what value?
for x in range(3):
print "Hi"
0
In the following loop the control variable starts x starts at what value?
for x in range(1,3):
print "Hi"
1
In the following loop the condition is______?
for x in range(3):
print "Hi"
x<3
In the following loop the condition is______?
for x in range(1,3):
print "Hi"
x<3
What do we increase our control variable by each time we go through a for loop?
1
When do we stop looping?
when the condition is false
We include the increment/decrement of the control variable when writing a _______and _________loops.
(ex: y +=1- y is the control variable)
while and nested
On a nested loop, if the outer loop is true, we execute the inner loop until ____________
it is false
On a nested loop, the inner loop control value _________every time we go back to outer loop
resets
what is the output?
for x in range(3):
print "Hi"
Hi
Hi
Hi
What is the output?
for x in range(1,3):
print "Hi"
Hi
Hi
What is the output?
x = 2
while x <7:
print "Hi",
x = x+1
Hi Hi Hi Hi Hi
What is the output?
for x in range(3):
print "x is", x
for y in range(2):
print "y is", y
print
x is 0
y is 0
y is 1
x is 1
y is 0
y is 1
x is 2
y is 0
y is 1
THIS SET IS OFTEN IN FOLDERS WITH...
Python - If, if - else, elif
20 terms
Python: Strings, Tuples and Lists
14 terms
Exam review/ Computers
40 terms
PowerShell
24 terms
YOU MIGHT ALSO LIKE...
Chapter 5 - Loops
29 terms
Domain/Range of Inverse Trig Functions
12 terms
trigonometric inverse graphs
6 terms
6.1 Trigonometry Inverse Graph Informati…
15 terms
OTHER SETS BY THIS CREATOR
Lesson 01: OOP, Methods, and Parameters, Graphics
34 terms
Ch 15 Sorting and Searching
12 terms
0b: Data Types and Variables
25 terms
Ch. 14 Arrays
17 terms
OTHER QUIZLET SETS
Engliish 100 Flashcards for Research Paper
20 terms
Lecture 7: Disorders of Hematopoiesis
53 terms
PHAR1101 Quiz 3 - The Oldest Drugs
40 terms
Ocular Anatomy 2018
68 terms