CS 1400 Unit 3 Basics Quiz
both operands are true.
A Boolean expression using the and operator returns True when one operand is true. both operands are equal. both operands are true. neither operand is true.
running a set of statements a predictable number of times. counting through a sequence of numbers.
A for loop is convenient for making choices in a program. describing conditional iteration. running a set of statements a predictable number of times. counting through a sequence of numbers.
entry-controlled loop.
By default, the while loop is an infinite loop exit-controlled loop. entry-controlled loop. continuation loop
The loop is infinite.
Consider the following code segment:count = 1while count <= 10:print(count, end = " ")Which of the following describes the error in this code? The loop is infinite. The loop is off by 1. The loop control variable is not properly initialized. The comparison points the wrong way.
5 4 3 2
Consider the following code segment:count = 5while count > 1:print(count, end = " ")count -= 1What is the output produced by this code? 2 3 4 5 5 4 3 2 5 4 3 2 1 1 2 3 4 5
At least one
Consider the following code segment:theSum = 0.0while True:number = input("Enter a number: ")if number == ":breaktheSum += float(number)How many iterations does this loop perform? Ten Zero or more At least one None
4
Consider the following code segment:x = 5y = 4if x > y:print( y )else:print( x )What value does this code segment print? > 4 5 0
10 times
How many times does a loop with the header for count in range (10): execute the statements in its body? 1 time 11 times 9 times 10 times
0 1 2 3 4
What is the output of the loop for count in range(5): print(count, end = " ")? 1 2 3 4 5 5 6 7 8 9 1 2 3 4 0 1 2 3 4
The last value of a sequence of integers minus 1
When the function range receives two arguments, what does the second argument specify? The first value of a sequence of integers The last value of a sequence of integers The last value of a sequence of integers minus 1 The last value of a sequence of integers plus 1