Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Login

Register Now

Welcome to All Test Answers

Quiz 7

• Question 1

In Python, an infinite loop usually occurs when the computer accesses an incorrect memory address.
Answers: True
False

Question 2

The first line in a while loop is referred to as the condition clause.
Answers: True
False

Question 3

student = 1
while student <= 3:
total = 0
for score in range(1, 4):
score = int(input(“Enter test score: “))
total += score
average = total/3
print(“Student “, student, “average: “, average)
student += 1
Answers: It accepts 3 test scores for each of 3 students and outputs the average for each student.
It accepts one test score for each of 3 students and outputs the average of the 3 scores.
It accepts 4 test scores for 2 students, then averages and outputs all the scores.
It accepts 4 test scores for 3 students and outputs the average of the 12 scores.

Question 4

What type of loop structure repeats the code a specific number of times?
Answers: Boolean-controlled loop
count-controlled loop
number-controlled loop
condition-controlled loop

Question 5

What type of loop structure repeats the code based on the value of Boolean expression?
Answers: Boolean-controlled loop
condition-controlled loop
count-controlled loop
number-controlled loop

Question 6

What type of loop structure repeats the code based on the value of Boolean expression?
Answers: condition-controlled loop
count-controlled loop
number-controlled loop
Boolean-controlled loop

Question 7

What type of loop structure repeats the code a specific number of times?
Answers: number-controlled loop
count-controlled loop
Boolean-controlled loop
condition-controlled loop

Question 8

In a while loop, the line beginning with while is called a(n) __.

Answers: a. intro
b. header
c. precursor
d. starter

Question 9

a = [‘CS106’, ‘CS212’, ‘CS310’, ‘CS410’]

s = ‘CS20791’
i = 0
while i < len(a):
if a[i] == s:
# Processing for item found
break
i += 1
else:
# Processing for item not found
print(s, ‘not found in list.’)

Answers: a.
CS106 found in list.
b.
CS20791 found in list.
c.
CS20791 not found in list.
d.
Answer a and c

Question 10

while a:
print(a[2])
break
Answers:

a. baz
b. foo
c. bar
d. none of the above

About

Leave a reply

Captcha Click on image to update the captcha .

error: Content is protected !!