Which type of loop causes a statement or set of statements to repeat a specific number of times?

Causes a statement or set of statements to execute repeatedly

What is a repetition structure also known as?

Condition-controlled loop

Uses a true/ false condition to control the number of times it repeats

*In Python, the While statement is used to demonstrate the condition-controlled loop

Repeats a specific number of times

•In Python, the for statement is used to demonstrate the count-controlled loop.

(A condition controlled loop)
•causes a statement or set of statements to repeat as long as a condition is true.

While a condition is true, do some task.

What are the two parts of the while loop?

1. A condition that is tested for a true/ false value

2. A statement or set of statements that is repeated as long as the condition is true

while condition:
statement
statement
etc.

What is the first statement of the while loop?

The while clause The while clause begins with the word while, followed by a Boolean condition that will be evaluated as either true or false.

While the loop is executed, the condition is tested.

If true, statements executed and loop starts again.

If false, program exits loop.

What is each execution of the body of a loop known as?

Condition is tested before performing an iteration

Continues to repeat until the program is interrupted. Occurs when programmer forgets to write code inside the loop that makes the test condition false.

Iterates a specific number of times.

In Python, the for statement illustrates a count-controlled loop

for variable in [value1 value2 etc]
statement
statement
etc.

What is the first line of a for loop called?

Inside the brackets of a for clause, a sequence of values appears, with a comma separating each value.

This is called a list

The for statement executes in the following manner:

The variable is assigned the first value in the list, and the statements in the block are executed again. This continues until variable has been assigned the last value in the list.

The variable used in the for clause. It is the target of an assignment at the beginning of each loop iteration.

Simplifies the process of writing a count-controlled for loop.

Creates an “iterable” object which is similar to a list. It contains a sequence of values that can be iterated over with something like a loop.

for num in range(5):
print (num)

•will generate an iterable sequence of integers in the range of 0, up to (but not including) 5

for num in range (1,5):
print (num)

Code will display:
1
2
3
4

•by default, the range function produces a sequence of numbers that increase by 1 for each successive number in the list.

•if you pass a third argument to the range function, that argument is used as a step increment.

•instead of increasing by 1, each successive number in the sequence will increase by the step value.

for num in range(1, 10, 2):
print(num)

Code will display the following

1
3
5
7
9

Generating an iterable sequence that ranges from highest to lowest

A sum of numbers that accumulates with each iteration of a loop. The variable used to keep the running total is called an accumulator.

The variable used to hold the running total

Programs that calculate the total of a series of numbers typically use two elements:

1. A loop that reads each number in the series

2. A variable that accumulates the total of the numbers as they are read

A condition-controlled loop can be used to iterate the body of the loop a specific number of times. A While loop repeats infinitely when there is no statement inside the loop body that makes the test condition false.

Which of the following is the structure that causes a statement or set of statements to execute repeatedly?

A repetition structure causes a statement or set of statements to execute repeatedly. Repetition structures are used to perform the same task over and over. A condition-controlled loop uses a Boolean (true/false) condition to control the number of times that it repeats.

What is the structure that causes a statement or a set of statements to execute repeatedly quizlet?

More commonly known as a loop, a repetition structure causes a statement or set of statements to execute repeatedly as many times as necessary. What is a condition-controlled loop? A condition-controlled loop causes a statement or set of statements to repeat as long as a condition is true.

Which statement is false about infinite loop?

An infinite loop is a commonly the result of a syntax error. Which statement is false about infinite loop? The body of a while loop eventually must make the condition false to avoid infinite loop. An infinite loop is generally caused by a programming mistake.

What is the structure that causes a statement?

A loop is a control structure that causes a statement or group of statements to repeat.  We will discuss three (possibly four) looping control structures. They differ in how they control the repetition. o This continues until the test of the BooleanExpression results in false.

What are the 3 actions that need to be taken for a loop to work successfully?

The loop consists of three important parts: the initialisation, the condition, and the update. In the initialisation step, you set up the variable which you’re going to use in the condition.

What does the following statement mean num1 num2 Get_num ()?

What does the following statement mean? num1, num2 = get_num() The function get_num() is expected to return a value each for num1 and num2. The randrange function returns a randomly selected value from a specific sequence of numbers.

Can be called from statements in the body of any loop?

A loop that contains a nested, inner loop. The loop has two parts: (1) a condition is tested for a true or false value (2) a statement or set of statements that is repeated as long as the condition is true. The while loop is known as a pretest loop. Modules can be called from statements in the body of any loop.

Is a for loop A count controlled loop?

The for loop as a Count-Controlled loop iterates a specific number of times. In the for clause, variable is the name of a variable.

Which type of loop causes a statement or set of statements to repeat as long as a condition is true?

Which pair of loops causes a statement or set of statements to repeat as long as a condition is true? The While loop is known as a pretest loop, which means it tests its condition before performing an iteration.

What type of loop structure repeats the code a specific number of times?

A count-controlled loop repeats a specific number of times.

What is the repetition of a loop called?

 Each repetition of a loop is called an iteration.  The while loop is known as a pretest loop, because it tests the boolean expression before it executes the statements in its body.

What is the structure that causes a statement or set of statements to execute repeatedly?

A repetition structure causes a statement or set of statements to execute repeatedly. Repetition structures are used to perform the same task over and over. A condition-controlled loop uses a Boolean (true/false) condition to control the number of times that it repeats.