(07CH5)

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

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

Counting Counting Counting Counting

Which of the following code will print all odd numbers between 3 and 11, each number separated by a space as shown below: 3 5 7 9 11

For I in range (3, 12, 1): If i%2 != 0: Print (i. And = " ")

which of the following for loops does the same thing as this while loop: count = 2 while count < 10: print (count) count += 2

for count in range (2,10,2): print (count)

What code would produce the following result: *** *** *** *** *** ***

for row in range (5): for col in range (3) : print ('*', end=' ') print ()

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

when keep_on_going refers to a value equal to 999

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 code prints the sum of numbers 1 to 5?

Total = 0 for number in range (1,6): Total += number Print(total)

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

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) :

True

The following is an example of a nested loop: for minutes in range (60): for seconds in range (60): print (minutes, ' : ' , seconds)

True

The following statement adds 1 to the variable count: count += 1

True

The output of the following code is _____ n = 2 while n < 6: n += 1 print (n, end = " ")

3 4 5 6

What will be displayed after the following code is executed? 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 is the output of the following code? for r in range (1, 3): for c in range (1, 2) : print (c, end = '") print ()

1 1

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

1 3 6

How many iterations will this loop go through (Hint: an iteration is how many times the line(s) inside the loop will execute): end = 10 for number in range (1, end+1): print (number)

10

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

2, 4, 6, 8

A(n) _____ loop usually occurs when the programmer does not include code inside the loop that makes the test condition false.

Infinite

What does the following program do? student = 1 while student <= 3: total = 0 for score in range (1, 4) : score = int (input ("Enter test score: ")) total += score average = total/3 print ("Student ", student, "average: ", average) student += 1

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


Ensembles d'études connexes

Kinesiology Ch4 Shoulder Complex

View Set

[INCOMPLETE] thePoint :: Chapter 15: Assessing Head and Neck :: NCLEX-Style Review Questions

View Set

Funeral Operations: Module Three

View Set

Boardvitals (Intra-Operative Procedures)

View Set

Lesson 2 - Thermal Energy Transfers

View Set

Human Resource Management Test 2 - Quinn Texas State

View Set

(A) C. 1: Scientific Thinking in Psychology:

View Set