Chapter 4 quiz

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What are the values that the variable num contains through the iterations of the following for loop? for num in range(4)

0, 1, 2, 3

What are the values that the variable num contains through the iterations of the following for loop? for num in range (2, 9, 2)

2, 4, 6, 8

What is not an example of an augmented assignment operator?

<=

The variable used to keep the running total is called a(n) ________.

Accumulator

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

Condition-controlled loop

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

Count-controlled loop

True/False: Functions can be called from statements in the body of a loop, and loops can be called from the body of a function.

False

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

False

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

False

What is the disadvantage of coding in one long sequence structure?

If parts of the duplicated code have to be corrected, the correction has to be made many times.

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

Input Validation

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

List

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

Repetition

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

True/False: A better 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 the statements as many times as necessary.

True

True/False: 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):

True

True/False: In a nested loop, the inner loop goes through all of its iterations for every single iteration of an outer loop.

True

True/False: In flowcharting, the decision structure and the repetition structure both use the diamond symbol to represent the condition that is tested.

True

True/False: Reducing duplication of code is one of the advantages of using a loop structure.

True

True/False: 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 correct data.

True

True/False: To get the total number of iterations of a nested loop, multiply the number of iterations of all the loops.

True

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

When keep_on_going refers to a value equal to 999

What is the format for the while clause in Python?

while condition :

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

Priming Read

Which of the following represents an example to calculate the sum of the numbers (accumulator)?

total += number


Ensembles d'études connexes

APUSH Unit 3: Overlapping Revolutions

View Set

Ch. 7: Forensic Biometrics, FORENSICS

View Set

Mechanics and Materials Quiz 4 Concepts

View Set

Chapter 09: Teaching and Counseling FUNDA

View Set

Introduction to the Internet and World Wide Web Ch.1

View Set

Macroeconomics Chapters 3, 4, & 5

View Set