Python Chapter 3 AP TEST

¡Supera tus tareas y exámenes ahora con Quizwiz!

The following for loop iterates __________ times to draw a square for x in range(4): turtle.forward(200) turtle.right(90)

4, four

Which of the following is not a an augmented assignment operator? A) <= B) *= C) /= D) +=

A) <=

In Python the _______ symbol is used as the equality operator. A) == B) <= C) != D) <=

A) ==

When using the _____ logical operator, both subexpressions must be true of the compound expression to be true. A) and B) either Or or And C) Or D) Not

A) and

What is the result of the following Boolean expression, given that x = 5, y = 3, and z =8? x < y or z > x A) 8 B) True C) False D) 5

B) True

A Boolean Variable can reference one of two values which are A) Y or N B) True or False C) T or F D) yes or no

B) True or False

When using the ______ logical operator, one or both of the sub-expressions must be true for the compound expression to be true: A) not B) or C) and D) Maybe

B) or

In Python, the _______ symbol is used as the not-equal-to operator. A) == B) <= C) <> D) !=

D) !=

True or False A while loop is called a pretest loop because the condition is tested after the loop has had one iteration.

False

True or False In Python, an infinite loop usually occurs when the computer accesses an incorrect memory address.

False

True or False To get the toatl number of iterations in a nested loop, add the number of iterations in the inner loop to the number in the outer loop.

False

The _______ statement is used to create a decision structure

If

The turtle.isdown() function returns _________ if the turtle's pen is down

True

True or False The integrity of a programs output is only as good as the integrity of it's input. For this reason, the program should discard input and prompt the user to enter valid data.

True

True or False the following code snippet will change the turtle's pen size to 4 if it is presently less than 4: if turtle.pensize() < 4 turtle.pensize(4)

True

True or False An action in a single alternative decision structure is performed only when the condition is true.

True

A(n) _______ expression is made up of two or more Boolean expressions.

compound

In a decision structure, the action is ______ executed because it is performed only when a specific condition is true.

conditionally

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

counting counting counting counting

In flowcharting, the _______ symbol is used to represent a Boolean Expression

diamond

Boolean variables are commonly used as _______________ to indicate whether a specific condition exists.

flags

In Python, you would use the __________ statement to write a count-controlled loop.

for

Python provides a special version of a decision structure known as the _______________ statement, which makes the logic of the nested decision structure simpler to write.

if-elif-else

A(n) _______ statement will execute one block of statements if its condintion is true or another block if its condition is false.

if-else

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

infinite

A(n) _________ is a special value that marks the end of a sequence of items.

sentinel

What does the following expression mean? x <= y

x is less than or equal to y

What are the values that the variable num contains through the iterations of the following for loop? for num in range(4): A) 1, 2, 3, 4 B) 1, 2, 3 C) 0, 1, 2, 3, 4 D) 0, 1 , 2, 3

D) 0, 1 , 2, 3

What is the result of the following Boolean expression, given that x = 5, y = 3, and z = 8? A) 5 B) 8 C) True D) False

D) False

What is the result of the following Boolean expression, given that x = 5, y =3, and z = 8? not(x < y or z > x) and y < z A) 8 B) True C) 5 D) False

D) False

Which of the following will determine if the turtle's pen is up and will change it to down if that is the case? A) if turtle.isdown B) if turtle.isup(): turtle.penup() turtle.isdown() C) if not(turtle.penup()) D) if not(turtle.isdown()): turtle.penup() turtle.pendown()

D) if not(turtle.isdown()): turtle.pendown()

Which logical operators perform short-circuit evaluation? A) and, or, not B) or, not C) not, and D) or, and

D) or, and

A variable used to keep a running total is called a(n) A) total B) running total C) summer D) accumulator

D)accumulator

Which of the following is the correct if clause to determine whether y is in the range 10 through 50, inclusive? A) if 10 < y or y > 50: B) if y >= 10 and y <= 50: B) if 10 > y and y<50: D) if y >= 10 or y <= 50:

B) if 10 > y and y<50:

Which of the following will hide the turtle if it is visible? A) if turtle.isvisible(): B) if turtle.isvisible(): turtle.invisible() turtle.hideturtle() C) turtle.isvisible(): D) if turtle.isvisible turtle.hide() turtle.hideturtle()

B) if turtle.isvisible(): turtle.hideturtle()

Which of the following represents an example to calculate the sum of numbers (that is, an accumulator), given that the number is stored in the variable number and the total is stored in the variable total? A) total + number = total B) total += number C) number += number D) total = number

B) total += number

What are the values that the variable num contains through the iterations of the following for loop? for num in range(2,9,2): A) 2, 5, 8 B) 2, 3, 4, 5, 6, 7, 8, 9 C) 2, 4, 6, 8 D) 1, 3, 5, 7, 9

C) 2, 4, 6, 8

what will be displayed after teh following code is executed? for num in range(0, 20, 5): num += num print(num) A) 0 5 10 15 20 B) 25 C) 30 D) 5 10 15

C) 30

What will be displayed after the following code is executed? total = 0 for count in range(4,6): total += count print(total) A) 4 B) 9 C)4 D) 4 5 9 5 6

C) 4 9

What will be displayed after the following code is executed? total = 0 for count in range(1,4): total += count print(total) A) 1 B) 5 C) 6 D) 1 4 3 6

C) 6

Which of the following is the correct if clause to determine whether choice is anything other than 10? A) if choice <> 10: B) if choice != 10 C) if choice !=10: D) if not(choice < 10 and choice > 10):

C) if choice != 10:

True or False Python allows you to compare strings, but it is not case sensitive.

False

True or False Short-circuit evaluation is only performed with the not operator.

False

True or False The not operator is a unary operator which must be used in a compound expression.

False

True or False A good way to repeatedly perform an operation is to write the statements for the task once and then place the statements in a loop that will repeat as many times as necessary.

True

True or False Decision structures are also known as selection structures.

True

True or False The following statement will check to see if the turtle's pen color is 'green': if turtle.pencolor() = 'green':

False

True or False Python uses the same symbols for the assignment operator as for the equality operator.

False

True or False The Python Language is not sensitive to block structuring of code.

False

True or False 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

True or False Expressions that are tested by the if statement are called Boolean expressions.

True

True or False In a flowchart, both the decision structure and the repetition structure use the diamond symbol to represent the condition that is tested.

True

True or False In a nested loop, the inner loop goes through all of its iterations for each iteration of the outer loop.

True

True or False Nested decision statements are one way to test more than one condition.

True

True or False Reducing duplication of code is one of the advantages of using a loop structure.

True

True or False The if statement causes one or more statements to execute only when a Boolean expression is true.

True

True or False In order to draw an octagon with turtle graphics, you wouold need a loop that iterates eight times.

True

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)

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

the logical _____ operator reverses the truth of a Boolean expression.

not

The _________ function is a built-in function that generates a list of integer values.

range

A(n) _____ operator determines whether a specific relationship exists between two values.

relational

A(n) ______ decision structure provides only one alternative path of execution.

single alternative

When will the following loop terminate? While keep_going != 999: A) when keep_going refers to a value less than 999 B) when keep_going refers to a value not equal to 999 C) when keep_going refers to a value greater than 999 when keep_going refers to a value

when keep_going refers to a value


Conjuntos de estudio relacionados

3.1.2 Social Engineering Overview Facts

View Set

Homeostasis and the Internal Environment

View Set

BIO 2700 (Evolution) Final Study Guide

View Set

Psychology Chapter 6, Chapter 7, Chapter 9,Chapter 10: Chapter 11Chapter 12...

View Set

Corporate Finance Final Exam Review

View Set

Choice of words (Analysis Non-Fictional Text)

View Set

Exam Prep 70-768 (Data Modeling)

View Set