Software Development Chapter 4 Quiz

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

accumulator

A ____ variable is used to keep a running total summer accumulator totalizer sentinel flag

sentinel

A ____ variable is used to keep track of when to exit (or stay in) a loop boolean integer accumulator sentinel

infinite loop

A common error in working with loops, in which the condition for exiting the loop is never met, is called a/an ____ indeterminate loop syntax error infinite loop overflow loop

a c d e

A for loop is a. allows for a user specified (run-time) ending counter value b. must have the number of times to iterate known at compile/coding time c. is a count controlled loop d. allows for a user specified (run-time) number of iterations e. allows for a user specified (run-time) starting counter value

iteration

Each time a program executes the body of a loop is called a/an ____ pre-test conditional iteration solution post-test

a b c d

Loops are commonly used for a. performing an operation a preset number of times b. performing an operation a variable number of times c. processing lists of data d. data input and validation

a

Nested loops (i.e. loops within loops) a. work through all iterations of an inner loop, for each iteration of the outer loop b. are not possible in Python c. work through all iterations of the outer loop, for each iteration of the inner loop d. are not generally a useful programming construct

pre-test loop

The while loop is a ___ post-test loop no-test loop counting loop pre-test loop

c

Validation loops are also known as a. error propagation loops b. froot loops c. error handlers d. iterative loops

b

What is the result of this program fragment, if the original input values are -15 for hours and 10.0 for rate (when you meant to enter 15 and 10)? hours = int(input('Enter hours worked: ')) rate = float(input('Enter pay rate in dollars per hour: ')) while hours < 0 or rate < 0: &nbsp; print ('Error, both values must be positive numbers. \ Please reenter') pay = hours * rate print('Your gross pay is ', pay) a. -150 is output b. the program is an infinite loop c. the program has a syntax error, because a rate or hours of zero makes no sense d. 150 is output

14

What is the value of x at the end of this program fragment? x = 7 x *= 2 7 9 syntax error, *= is not a valid Python operator 14


Ensembles d'études connexes

History and Development of Mobile Phones

View Set

PEDS Chapt 24 Nursing Care of the Child with an Integumentary Disorder

View Set

BIOCHEMISTRY TOPIC 5: PROTEIN FOLDING AND LEVELS OF PROTEIN STRUCTURE

View Set

Study Questions for History 7-12

View Set