Quiz 3 Flashcards

1
Q

What is the output?
word = “Anaconda”
for letter in word:
print (letter, word)

A
A Anaconda
n Anaconda
a Anaconda
c Anaconda
o Anaconda
n Anaconda
d Anaconda
a Anaconda
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
What is the output?
count = 0
while count <5
      print(count)
      count = count + 1
A
0
1
2
3
4
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
What is the output?
num = 5
while num > 0
      num = num - 1
      print (num)
A
4
3
2
1
0
-1
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
What is the output?
letter_count = ""
for char in "12345":
    letter_count = letter_count +char
    print(count)
A
1
12
123
1234
12345
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the output?
saying = “Cyrus Turnbul.” #line1
print (saying [4:9]) #line 2

A

s Tur

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What type of loop is a count controlled loop?

A

for loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What type of loop uses a Boolean statement to control the loop?

A

while loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Each repetition of a loop is known as a(n)_________.

A

iteration

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

The *= operator is an example of a(n) __________ operator.

A

augmented assignment

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

The *= operator is an example of a(n) __________ operator.

A

augmented assignment operator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
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
A

X = 2
while X <= 10:
print(format(X, “.0f”))
X += 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How many times will “Hello, It’s me.” be printed in the following program?
count = 10
while count >=10:
print(“Hello, It’s me.”)

A

infinite

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What will the following code display?
for number in range(6):
print(number)

A
0
1
2
3
4
5
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What will the following code display?
for number in range(2,6):
print(number, end = “ “)

A

2 3 4 5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What will the following code display?
for number in range(0, 501, 100):
print(number)

A
0
100
200
300
400
500
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What will the following code display?
for i in range(7,12):
print(i, end = ‘ ‘)

A

7 8 9 10 11

17
Q

Write a for loop that will print the numbers between 6 and 100 that are evenly divisible by 2. Include 6 and 100.

A

for x in range (6,100,2):

18
Q

Write a program that has the user enter a positive integer greater than one. Using a for loop print each integer from that number down to but not including 1:

A

x = int(input(“Please enter a number greater than 1: “))
for y in range(1,x):
print(x)
x = x-1

19
Q

A(n) __________ variable keeps a running total.

A

a.Sentinel b.Sum c.Total d.Accumulator

20
Q

and, or and not are ___________ operators.

A

logical operators.

21
Q

When a program compares characters, it actually compares the __________ codes

A

ASCII

22
Q

Write a program that has the user enter an int. Using a for loop print each int from that number down to but not including 0

A

x = int(input(“Please enter an integer: “))
for y in range(0,x):
print(x)
x = x-1

23
Q

What is the output?
word = “John Boy”
for ch in word:
print(ch)

A

J
o
h
n

B
o
y

24
Q

What is the output?
for alpha in “abet”:
print(“Hooray!”)

A

Hooray!
Hooray!
Hooray!
Hooray!

25
Q

What is the output?
for letter in “abcdefg”:
if letter in “aeiou”
print(letter)

A

a

e

26
Q
What is the output?
word = “Mississippi”
for letter in word:
         if letter != “s”and letter !=“p”:
                    print(letter)
A
M
i
i
i
i
27
Q

num = 0
while num < 10:
print(num)
num = num + 2

A
0
2
4
5
8