CIS 201 Test 3

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

What comparison operator is used to test whether an expression does NOT equal another expression?

!=

What character is used as the format operator when formatting output?

%

What is NOT a Boolean or logical operator used in the Python language?

xor

What is a count controlled loop?

It is a loop that counts through a range of numbers to control when the loop ends.

In programming, what is a prototype?

It is a rough draft of a program.

What is a one-way selection statement in the context of Python?

It is a single if statement without a corresponding else statement used to test a condition and run statements, then proceed to the next statement.

In a conditional iteration loop, such as a while loop, what is a sentinel value?

A sentinel value is a special value provided by the user to terminate the loop.

Inside of a loop, after a termination condition has been met, what statement can be used to cause an exit from the loop and execute the remainder of the script?

Break

You are running a Python script and suspect that the script has entered an infinite loop. What key combination can you use to halt the loop?

CTRL + c

What statement should you use to print the value of total with a precision of 5 digits?

print("The total is %0.5f" % total)

In general terms, what does a selection statement do?

It allows a computer to make choices based on test conditions.

"A" < "B" evaluates to False.

False

4 != 4 evaluates to True.

False

Assuming that the value of x is 4, and the value of y is 6, what is the value of the following expression? (x - y)**2 > y

False

For the most part, off-by-one errors result when the programmer incorrectly specifies the lower bound of the loop.

False

If A is True, what will the statement "not A" return?

False

In Python, = means equals, whereas == means assignment.

False

Loop statements allow a computer to make choices.

False

The Boolean data type is named for the twentieth-century British mathematician George Boole.

False

The augmented assignment operations have a higher precedence than the standard assignment operation.

False

The if-else statement is the most common type of selection statement.

False

The not operator has a lower precedence than the and and or operators.

False

The or operator returns True if and only if both of its operands are true, and returns False otherwise.

False

The simplest form of selection is the if-else statement.

False

The statements in the loop body need not be indented and aligned in the same column.

False

The statements within a while loop can execute one or more times.

False

The while loop is also called a sentinel-control loop, because its condition is tested at the top of the loop.

False

What is the minimum number of spaces that should be used to create an indented statement?

Four spaces

An off-by-one error is an example of what type of error in programming?

Logic error

What statement regarding precedence of operators is accurate?

The comparison operators (==, !=, <, >, <=, >=) are higher in precedence than the assignment operator (=).

What part of the loop comprises the statements to be executed?

The loop body

When using the range function, what effect does the specification of a third argument have?

The third argument specifies a step value to be used in the range.

In evaluating a loop, you find the following statement "value += 1". What happens to the value variable upon each iteration of the loop?

The variable is increased by 1 each iteration through the loop.

Given the following statement: "%4d" % var1, which of the following is accurate?

The variable var1 must be an integer value.

A condition expresses a hypothesis about the state of its world at that point in time.

True

A while loop can be used for a count-controlled loop.

True

Although the while loop can be complicated to write correctly, it is possible to simplify its structure and thus improve its readability.

True

Conditional iteration requires that a condition be tested within the loop to determine whether the loop should continue.

True

Simple Boolean expressions consist of the Boolean values True or False, variables bound to those values, function calls that return Boolean values, or comparisons.

True

Some computer scientists argue that a while True loop with a delayed exit violates the spirit of the while loop.

True

The assignment symbol can be combined with the arithmetic and concatenation operators to provide augmented assignment operations.

True

The comparison operators are applied after addition but before assignment.

True

The not operator expects a single operand and returns its logical negation, True, if it's false, and False if it's true.

True

There are two types of loops -- those that repeat an action a predefined number of times(definite iteration) and those that perform the action until the program determines that it needs to stop (indefinite iteration).

True

When the step argument is a negative number, the range function generates a sequence of numbers from the first argument plus 1.

True

What scenario would it make logical sense to use a multi-way selection statement for?

You need to convert numeric grades to letter grades.

The use of +=, -=, and *= are all examples of what type of operators?

augmented assignment operators

What are the two different types of loops that are used within the Python language? (Choose two.)

definite iteration indefinite iteration

The while loop is also known as what kind of a loop?

entry-control loop

What function call will generate a random number in the range of 1 through 6 using the random module?

random.randint(1, 6)


Set pelajaran terkait

Management of Patients with Chest and Lower Respiratory Tract Disorders

View Set

Unit 15 - Methods of Persuasive Speaking

View Set