Concept explainers
A_________-controlled loop uses a true/false condition to control the number of times that it repeats.
a. Boolean
b. condition
c. decision
d. count
The “while” loop is a condition-controlled loop; it controls the number of times that the loop repeats.
Hence, the correct answer is option “B”.
Explanation of Solution
Condition controlled loop:
This is a loop that exhibits true or false condition to control the number of times that the loop repeats. For example, the “while” loop is a condition-controlled loop.
- The “while” loop first checks its expression, and then the statements inside the loop get executed. It is also called as pretest loops.
- The loop gets terminated when the condition becomes false.
Syntax:
Syntax for the “while” loop is as follows:
while boolean_expression:
# while suite
Example Program:
Consider the following example of the condition-controlled loop:
#initialization of variable
a=1
#execute the while loop until a is less than or equal to 5
while a<=5:
#Print the value of a
print(a)
#Increment a by 1 for each iteration of loop
a+=1
zOutput:
1
2
3
4
5
In the above code, the “while” loop executes until the value of “a” is less than or equal to 5, and then it exits from the program when the condition inside the loop fails.
Explanation for incorrect options:
Boolean:
Boolean is not a loop instead it is a data type that is represented with two values either true or false. This value is based upon the flow of the action performed by the program.
Hence, option “A” is wrong.
Decision:
A decision is not a loop, and it decides the case to be executed based upon the situation.
Hence, option “C” is wrong.
Count controlled loop:
This is a loop that repeats a specific number of times, and it keeps track of the counter variable to track about the number of times that the loop executes. For example, “for” loop is a counter-controlled loop.
Hence, option “D” is wrong.
Want to see more full solutions like this?
Chapter 4 Solutions
EBK STARTING OUT WITH PYTHON
Additional Engineering Textbook Solutions
Modern Database Management (12th Edition)
Concepts of Programming Languages (11th Edition)
Starting Out with Programming Logic and Design (4th Edition)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Digital Fundamentals (11th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
- (Mathematical functions) Write a program that calculates and displays values for y when y=xz/(xz) Your program should calculate y for values of x ranging between 1 and 5 and values of z ranging between 2 and 6. The x variable should control the outer loop and be incremented in steps of 1, and z should be incremented in steps of 1. Your program should also display the message Function Undefined when the x and z values are equal.arrow_forwardA ______ value is a special value that is used to terminate a loop when a set of data is being entered. Select one: a. Break b. Marker c. Control d. Sentinelarrow_forwardAll of the following are looping control structures except Select one: while loop do-while loop for loop do loop none; all of these are looping control structuresarrow_forward
- True or False: You should be incrementing the control variable of a for loop True or False: you can use the control variable of a while loop after the loop has finished executing True or False: you can nest repetition structures in repetition structures True or False: you can nest selection structure in selection structuresarrow_forwardThe statement For J = 3 To 12 Step 2 causes the loop to iterate _____ timesarrow_forwardIs a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times For-loop O .While O .Switch Oarrow_forward
- The while loop checks the loop-continuation-condition ______. Select one: a. First b. Last c. Continuously as the loop executes. d. Only when the loop-continuation-condition changes.arrow_forward* True Or False A break statement will leave the outer loop. True O False Oarrow_forwardBug Collector - MUST BE WRITTEN IN PSEUDOCODE A bug collector collects bugs every day for seven days. Design a program that keeps a running total of the number of bugs collected during the seven days. The loop should ask for the number of bugs collected for each day, and when the loop is finished, the program should display the total number of bugs collected.arrow_forward
- Sum of Numbers Problem Design a program in Python with a loop that asks the user to enter a series of positive numbers. The user should enter a negative number to signal the end of the series. After all the positive numbers have been entered, the program should display their sum.arrow_forwardAn action is taken if the condition is true, otherwise the control goes to the next statement. * Do While Loop Elself Statement Select Case Block If Statementarrow_forwardAn action is taken if the condition is true, otherwise the control goes to the next statement. * O If Statement O Do While Loop O Select Case Block Elself Statementarrow_forward
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr