Chapter 4 - Reading Quiz - Python

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

for num in range(0, 20, 5): num += num print(num)

30

A variable used to keep a running total is called a(n)

accumulator

What will be displayed after the following code is executed? count = 4 while count < 12: print("counting") count = count + 2

counting counting counting counting

A while loop is called a pretest loop because the condition is tested after the loop has had one iteration. T/F

False

Functions can be called from statements in the body of a loop and loops can be called from within the body of a function. T/F

False

In Python, an infinite loop usually occurs when the computer accesses an incorrect memory address. T/F

False

The first line in a while loop is referred to as the condition clause. T/F

False

To get the total number of iterations in a nested loop, add the number of iterations in the inner loop to the number in the outer loop. T/F

False

structure causes a set of statements to execute repeatedly.

Repetition

is a special value that marks the end of a sequence of items.

Sentinel

What type of loop structure repeats the code based on the value of Boolean expression?

condition-controlled loop

statement to write a count-controlled loop.

for

function is a built-in function that generates a list of integer values.

range

When will the following loop terminate? while keep_on_going != 999:

when keep_on_going refers to a value equal to 999

What will be displayed after the following code is executed? total = 0 for count in range(4,6): total += count print(total)

4 9

What will be displayed after the following code is executed? total = 0 for count in range(1,4): total += count print(total)

6

-controlled loop causes a statement or set of statements to repeat as long as the condition is true.

Condition

The acronym ________ refers to the fact that the computer cannot tell the difference between good data and bad data.

GIGO

________ is the process of inspecting data that has been input into a program in order to ensure that the data is valid before it is used in a computation.

Input Validation

student = 1 while student <= 3: etc

It accepts 3 test scores for each of 3 students and outputs the average for each student.

A good way to repeatedly perform an operation is to write the statements for the task once and then place the statements in a loop that will repeat as many times as necessary. T/F

True

Both of the following for clauses would generate the same number of loop iterations. for num in range(4): for num in range(1, 5): T/F

True

In a flowchart, both the decision structure and the repetition structure use the diamond symbol to represent the condition that is tested. T/F

True

In a nested loop, the inner loop goes through all of its iterations for each iteration of the outer loop. T/F

True

In order to draw an octagon with turtle graphics, you would need a loop that iterates eight times. T/F

True

Reducing duplication of code is one of the advantages of using a loop structure. T/F

True

The integrity of a program's output is only as good as the integrity of its input. For this reason, the program should discard input that is invalid and prompt the user to enter valid data. T/F

True

loop usually occurs when the programmer does not include code inside the loop that makes the test condition false.

infinite

validation loop is sometimes called an error trap or an error handler.

input

In Python, a comma-separated sequence of data items that are enclosed in a set of brackets is called

list

The while loop is known as a(n) ___________ loop because it tests the condition before performing an iteration.

pretest

The first operation is called the ________ and its purpose is to get the first input value that will be tested by the validation loop.

priming read

A(n) ________ structure is a structure that causes a statement or a set of statements to execute repeatedly.

repetition

total is a sum of numbers that accumulates with each iteration of the loop.

running

In Python, the variable in the for clause is referred to as the ________ because it is the target of an assignment at the beginning of each loop iteration.

target variable

Which of the following represents an example to calculate the sum of numbers (that is, an accumulator), given that the number is stored in the variable number and the total is stored in the variable total?

total += number

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

count-controlled loop


संबंधित स्टडी सेट्स

Chapter 8: Achievement and Aptitude Assessment

View Set

Chapter 13 sociology section quiz

View Set

Benchmark Adelante Grado 5 Unidad 3 Semana 1

View Set