CISP CH 4

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

How many times will 'Hello World' be printed in the following code? count = 10 while count < 1: print ('Hello World')

0

What will the following code display? for x in range(10, 15, 2): print(x)

10 12 14

What sequence of numbers will the following code display? for x in range(100, 0, -1): print(x)

100, 99, 98, ... 1

What will the following code display? total = 0 for count in range(1, 6): total = total + count print(total)

15

What will the following code display? number1 = 10 number2 = 5 number1 = number1 + number2 print(number1) print(number2)

15 5

What is the first step in a for loop?

The variable is assigned the first value in the sequence of data items.`

A sentinel value must be unique enough that it will not be mistaken as a regular value in the list.(t/f)

True

A while loop contains a statement or set of statements that is repeated as long as a condition is true.(t/f)

True

A while loop tests its expression _____.

before each iteration

A sentinel is a special value that marks the_________of a list of items.

end

If the condition is ________ in a while loop, the program exits the loop.

false

In Python, you use a while statement to write code that repeats a specific number of times.(t/f)

false(you would use a count controlled loop)

A for statement in Python has a typical format, as shown below, but without the header. What is the pseudocode of the "for" header used in this chapter? _______________________ statement: statement: Etc.

for value in {variable1, variable2, etc.}

How many times will 'Hello World' be printed in the following code? count = 10 while count >= 10: print ('Hello World') count +=1

infinite

An infinite loop repeats until the program is _____.

interrupted

An execution of the statements in the body of the loop is called a(n) _____.

iteration

A control structure that causes a statement or group of statements to repeat as many times as necessary is known as a(n) _____.

loop

A condition-controlled loop in Python _____.

relies on a true-false state

A count-controlled loop in Python _____.

repeats a specific # of times

The variable used in a for clause is known as the ____________variable of an assignment at the beginning of each loop iteration.

target

An important characteristic of the while loop is that the loop will never iterate if the test expression is false to start with.(t/f)

true


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

IR spectrometry signals (fingerprint region)

View Set

NY Life and Health Chapter Quizzes

View Set

English: Satire in The Pardoner's Tale

View Set

Programmable Logic Controllers Basics

View Set

5.2.3 factors affecting processor performance

View Set

Ch.16 Fire Suppression Systems - State Final Review

View Set