Quiz 3 Flashcards
What is the output?
word = “Anaconda”
for letter in word:
print (letter, word)
A Anaconda n Anaconda a Anaconda c Anaconda o Anaconda n Anaconda d Anaconda a Anaconda
What is the output? count = 0 while count <5 print(count) count = count + 1
0 1 2 3 4
What is the output? num = 5 while num > 0 num = num - 1 print (num)
4 3 2 1 0 -1
What is the output? letter_count = "" for char in "12345": letter_count = letter_count +char print(count)
1 12 123 1234 12345
What is the output?
saying = “Cyrus Turnbul.” #line1
print (saying [4:9]) #line 2
s Tur
What type of loop is a count controlled loop?
for loop
What type of loop uses a Boolean statement to control the loop?
while loop
Each repetition of a loop is known as a(n)_________.
iteration
The *= operator is an example of a(n) __________ operator.
augmented assignment
The *= operator is an example of a(n) __________ operator.
augmented assignment operator
Write a while loop that counts from two to ten by twos. The results of your loop will match the following: 2 4 6 8 10
X = 2
while X <= 10:
print(format(X, “.0f”))
X += 2
How many times will “Hello, It’s me.” be printed in the following program?
count = 10
while count >=10:
print(“Hello, It’s me.”)
infinite
What will the following code display?
for number in range(6):
print(number)
0 1 2 3 4 5
What will the following code display?
for number in range(2,6):
print(number, end = “ “)
2 3 4 5
What will the following code display?
for number in range(0, 501, 100):
print(number)
0 100 200 300 400 500