Chapter 3 - Self-Test Questions

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

What is the value of variable num after the following is executed? num = 10 num = num + 5 num == 20 num = num + 1

16

All if statements must contain either an else or elif header. True/False

False

What does the following expressions evaluate for name equal to 'Ann'? name in ('Jacob', 'MaryAnn', 'Thomas')

False

A while loop continues to iterate until its condition becomes false. True/False

True

A while loop executes zero or more times. True/False

True

All iteration can be achieved by a while loop. True/False

True

Which of the following Boolean expressions evaluate to True? a. 'Dave' < 'Ed' b. 'dave' < 'Ed' c. 'Dave' < 'Dale'

a

Which of the following expressions evaluate to True? a. 10 >= 8 b. 8 <= 10 c. 10 == 8 d. 10 != 8 e. '8' < '10'

a,b,d

Which of the following statements are true regarding headers in Python? a. headers begin with a keyword and end with a colon b. headers always occur in pairs c. all headers of the same compound statement must be indented the same amount

a,c

Evaluate the following Boolean expressions using the operator precedence rules of Python. a. 10 >= 8 and 5 != 3 b. 10 >= 8 and 5 == 3 or 14 < 5

a. True b. False

A compound statement is a. a statement that spans more than one line b. a statement that contains other statements c. a statement that contains at least one arithmetic expression

b

The elif header allows for a. multi-way selection that cannot be accomplished otherwise b. multi-way selection as a single if statement c. the use of a "catch-all" case in multi-way selection

b

The terms 'definite loop' and 'indefinite loop' are used to indicate whether a. a given loop executes at least once b. the number of times that a loop is executed can be determined before the loop is executed c. both of the above

b

Which one of the following Boolean expressions is not logically equivalent to the other two? a. not(num < 0 or num > 10) b. num > 0 and num < 10 c. num >= 0 and num <= 10

b

An infinite loop is an iterative control structure that a. loops forever and must be forced to terminate b. loops until the program terminates with a system error c. both of the above

c

Which of the following statements is true? a. statements within a suite can be indented a different amount b. statements within a suite can be indented a different amount as long as all headers in the statement that it occurs in are indented the same amount c. all headers must be indented the same amount as all other headers in the same statement, and all statements in a given suite must be indented the same amount

c

A Boolean flag is a. a variable b. has the value True or False c. is used as a condition for control statements d. all of the above

d

Three forms of control in programming are sequential, selection, and --- control.

iterative


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

Chapter 30: Atraumatic Care of Children and Families

View Set