Deck 3: Loops and Selection Statements

ملء الشاشة (f)
exit full mode
سؤال
The not operator has a lower precedence than the and and or operators.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
The comparison operators are applied after addition but before assignment.
سؤال
Conditional iteration requires that a condition be tested within the loop to determine whether the loop should continue.
سؤال
"A"
سؤال
The augmented assignment operations have a higher precedence than the standard assignment operation.
سؤال
When the step argument is a negative number, the range function generates a sequence of numbers from the first argument down to the second argument plus 1.
سؤال
A condition expresses a hypothesis about the state of its world at that point in time.
سؤال
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).
سؤال
For the most part, off-by-one errors result when the programmer incorrectly specifies the lower bound of the loop.
سؤال
The or operator returns True if and only if both of its operands are true, and returns False otherwise.
سؤال
Loop statements allow a computer to make choices.
سؤال
Simple Boolean expressions consist of the Boolean values True or False, variables bound to those values, function calls that return Boolean values, or comparisons.
سؤال
The assignment symbol can be combined with the arithmetic and concatenation operators to provide augmented assignment operations.
سؤال
The statements in the loop body need not be indented and aligned in the same column.
سؤال
4 != 4 evaluates to True.
سؤال
The if-else statement is the most common type of selection statement.
سؤال
The not operator expects a single operand and returns its logical negation, True, if it's false, and False if it's true.
سؤال
The simplest form of selection is the if-else statement.
سؤال
The Boolean data type is named for the twentieth-century British mathematician George Boole.
سؤال
In Python, = means equals, whereas == means assignment.
سؤال
Some computer scientists argue that a while True loop with a delayed exit violates the spirit of the while loop.
سؤال
Given the following statement: "%4d" % var1, which of the following is accurate?

A) The variable var1 must be an integer value.
B) The variable var1 must be a string value.
C) The variable var1 will be in octal format.
D) The variable var1 will be formatted regardless of type.
سؤال
In evaluating a loop, you find the following statement: "value += 1". What happens to the value variable upon each iteration of the loop?

A) The variable is reset to an int type, with a value of 1.
B) The variable's value is changed to a positive value.
C) The variable is increased by 1 each iteration through the loop.
D) The variable is incremented by itself.
سؤال
What statement should you use to print the value of total with a precision of 5 digits?

A) print("The total is %5." % total)
B) print("The total is %0.5d" % total)
C) print("The total is %f" % float(total, 5))
D) print("The total is %0.5f" % total)
سؤال
Although the while loop can be complicated to write correctly, it is possible to simplify its structure and thus improve its readability.
سؤال
What are the two different types of loops that are used within the Python language? (Choose two.)

A) predetermined looping
B) definite iteration
C) infinite cycling
D) indefinite iteration
سؤال
What comparison operator is used to test whether an expression does NOT equal another expression?

A) -=
B) !=
C) /=
D) _=
سؤال
What is the minimum number of spaces that should be used to create an indented statement?

A) one space
B) two spaces
C) three spaces
D) four spaces
سؤال
In a conditional iteration loop, such as a while loop, what is a sentinel value?

A) A sentinel value is a user-provided input value that proceeds to the next loop.
B) A sentinel value is a user-provided input value that changes the structure of the loop.
C) A sentinel value is a special value provided by the user to terminate the loop.
D) A sentinel value is a special value provided by the user to restart the loop.
سؤال
If A is True, what will the statement "not A" return?

A) Undefined
B) True
C) False
D) BooleanError
سؤال
What is a one-way selection statement in the context of Python?

A) 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.
B) It is a single if-else statement block that is used to test a condition and run statements, as well as provide a default path for execution.
C) It is a switch statement block that is used to direct the flow of data based on a single condition.
D) It is an if statement that tests no conditions, but provides a block for execution.
سؤال
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?

A) CTRL + Esc
B) CTRL + c
C) Alt + b
D) CTRL + Break
سؤال
What character is used as the format operator when formatting output?

A) ^
B) $
C) %
D) @
سؤال
When using the range function, what effect does the specification of a third argument have?

A) The third argument is used as the starting point for the range function.
B) The third argument specifies a step value to be used in the range.
C) The third argument declares an exponential value the numbers will be raised to.
D) The third argument is simply included in the sequence, assuming it wasn't already in the range.
سؤال
The while loop is also called a sentinel-control loop, because its condition is tested at the top of 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?

A) exit
B) break
C) quit
D) halt
سؤال
The while loop is also known as what kind of a loop?

A) infinite loop
B) operational loop
C) user-control loop
D) entry-control loop
سؤال
A while loop can be used for a count-controlled loop.
سؤال
An off-by-one error is an example of what type of error in programming?

A) logic error
B) syntax error
C) type error
D) input error
سؤال
The statements within a while loop can execute one or more times.
سؤال
What scenario would it make logical sense to use a multi-way selection statement for?

A) You need to convert numeric grades to letter grades.
B) You need to test if the value of A is larger than B.
C) You need to determine if a number is positive or negative.
D) You need to test if a variable is True or 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

A) True
B) False
C) Undefined
D) TypeError
سؤال
The use of +=, -=, and *= are all examples of what type of operators?

A) protracted assignment operators
B) augmented assignment operators
C) extended arithmetic operators
D) overloaded mathematic operators
سؤال
What is NOT a Boolean or logical operator used in the Python language?

A) and
B) or
C) not
D) xor
سؤال
In programming, what is a prototype?

A) It is a rough draft of a program.
B) It is a program in final stages of development.
C) It is a program statement that builds a module.
D) It is a production-ready program.
سؤال
In general terms, what does a selection statement do?

A) It forces a computer to favor one value over another.
B) It allows a computer to make choices based on test conditions.
C) It allows a computer to select the values that are most economical.
D) It allows a computer to selectively execute based on processing cost.
سؤال
What function call will generate a random number in the range of 1 through 6 using the random module?

A) random.randnum(1, 6)
B) random.randint(range(1-6))
C) random.randint(1, 6)
D) random.random(1, 6)
سؤال
What statement regarding precedence of operators is accurate?

A) The assignment operator (=) is higher in precedence than exponentiation (**).
B) The logical conjunction (and) is higher in precedence than the logical negation (not).
C) The comparison operators (==, !=, , =) are higher in precedence than the assignment operator (=).
D) The addition and subtraction operators (+, -) are lower in precedence than the logical conjunction operator (and).
سؤال
What part of the loop comprises the statements to be executed?

A) The loop header.
B) The loop body.
C) The loop end.
D) The loop tail.
سؤال
What is a count controlled loop?

A) It is a loop that counts iterations until a sentinel value is received.
B) It is a loop that continues based on a certain time interval.
C) It is a loop that prints out a count of values for the user.
D) It is a loop that counts through a range of numbers to control when the loop ends.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/50
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 3: Loops and Selection Statements
1
The not operator has a lower precedence than the and and or operators.
False
2
The comparison operators are applied after addition but before assignment.
True
3
Conditional iteration requires that a condition be tested within the loop to determine whether the loop should continue.
True
4
"A"
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
5
The augmented assignment operations have a higher precedence than the standard assignment operation.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
6
When the step argument is a negative number, the range function generates a sequence of numbers from the first argument down to the second argument plus 1.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
7
A condition expresses a hypothesis about the state of its world at that point in time.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
8
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).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
9
For the most part, off-by-one errors result when the programmer incorrectly specifies the lower bound of the loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
10
The or operator returns True if and only if both of its operands are true, and returns False otherwise.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
11
Loop statements allow a computer to make choices.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
12
Simple Boolean expressions consist of the Boolean values True or False, variables bound to those values, function calls that return Boolean values, or comparisons.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
13
The assignment symbol can be combined with the arithmetic and concatenation operators to provide augmented assignment operations.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
14
The statements in the loop body need not be indented and aligned in the same column.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
15
4 != 4 evaluates to True.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
16
The if-else statement is the most common type of selection statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
17
The not operator expects a single operand and returns its logical negation, True, if it's false, and False if it's true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
18
The simplest form of selection is the if-else statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
19
The Boolean data type is named for the twentieth-century British mathematician George Boole.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
20
In Python, = means equals, whereas == means assignment.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
21
Some computer scientists argue that a while True loop with a delayed exit violates the spirit of the while loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
22
Given the following statement: "%4d" % var1, which of the following is accurate?

A) The variable var1 must be an integer value.
B) The variable var1 must be a string value.
C) The variable var1 will be in octal format.
D) The variable var1 will be formatted regardless of type.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
23
In evaluating a loop, you find the following statement: "value += 1". What happens to the value variable upon each iteration of the loop?

A) The variable is reset to an int type, with a value of 1.
B) The variable's value is changed to a positive value.
C) The variable is increased by 1 each iteration through the loop.
D) The variable is incremented by itself.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
24
What statement should you use to print the value of total with a precision of 5 digits?

A) print("The total is %5." % total)
B) print("The total is %0.5d" % total)
C) print("The total is %f" % float(total, 5))
D) print("The total is %0.5f" % total)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
25
Although the while loop can be complicated to write correctly, it is possible to simplify its structure and thus improve its readability.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
26
What are the two different types of loops that are used within the Python language? (Choose two.)

A) predetermined looping
B) definite iteration
C) infinite cycling
D) indefinite iteration
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
27
What comparison operator is used to test whether an expression does NOT equal another expression?

A) -=
B) !=
C) /=
D) _=
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
28
What is the minimum number of spaces that should be used to create an indented statement?

A) one space
B) two spaces
C) three spaces
D) four spaces
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
29
In a conditional iteration loop, such as a while loop, what is a sentinel value?

A) A sentinel value is a user-provided input value that proceeds to the next loop.
B) A sentinel value is a user-provided input value that changes the structure of the loop.
C) A sentinel value is a special value provided by the user to terminate the loop.
D) A sentinel value is a special value provided by the user to restart the loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
30
If A is True, what will the statement "not A" return?

A) Undefined
B) True
C) False
D) BooleanError
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
31
What is a one-way selection statement in the context of Python?

A) 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.
B) It is a single if-else statement block that is used to test a condition and run statements, as well as provide a default path for execution.
C) It is a switch statement block that is used to direct the flow of data based on a single condition.
D) It is an if statement that tests no conditions, but provides a block for execution.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
32
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?

A) CTRL + Esc
B) CTRL + c
C) Alt + b
D) CTRL + Break
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
33
What character is used as the format operator when formatting output?

A) ^
B) $
C) %
D) @
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
34
When using the range function, what effect does the specification of a third argument have?

A) The third argument is used as the starting point for the range function.
B) The third argument specifies a step value to be used in the range.
C) The third argument declares an exponential value the numbers will be raised to.
D) The third argument is simply included in the sequence, assuming it wasn't already in the range.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
35
The while loop is also called a sentinel-control loop, because its condition is tested at the top of the loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
36
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?

A) exit
B) break
C) quit
D) halt
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
37
The while loop is also known as what kind of a loop?

A) infinite loop
B) operational loop
C) user-control loop
D) entry-control loop
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
38
A while loop can be used for a count-controlled loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
39
An off-by-one error is an example of what type of error in programming?

A) logic error
B) syntax error
C) type error
D) input error
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
40
The statements within a while loop can execute one or more times.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
41
What scenario would it make logical sense to use a multi-way selection statement for?

A) You need to convert numeric grades to letter grades.
B) You need to test if the value of A is larger than B.
C) You need to determine if a number is positive or negative.
D) You need to test if a variable is True or False.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
42
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

A) True
B) False
C) Undefined
D) TypeError
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
43
The use of +=, -=, and *= are all examples of what type of operators?

A) protracted assignment operators
B) augmented assignment operators
C) extended arithmetic operators
D) overloaded mathematic operators
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
44
What is NOT a Boolean or logical operator used in the Python language?

A) and
B) or
C) not
D) xor
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
45
In programming, what is a prototype?

A) It is a rough draft of a program.
B) It is a program in final stages of development.
C) It is a program statement that builds a module.
D) It is a production-ready program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
46
In general terms, what does a selection statement do?

A) It forces a computer to favor one value over another.
B) It allows a computer to make choices based on test conditions.
C) It allows a computer to select the values that are most economical.
D) It allows a computer to selectively execute based on processing cost.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
47
What function call will generate a random number in the range of 1 through 6 using the random module?

A) random.randnum(1, 6)
B) random.randint(range(1-6))
C) random.randint(1, 6)
D) random.random(1, 6)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
48
What statement regarding precedence of operators is accurate?

A) The assignment operator (=) is higher in precedence than exponentiation (**).
B) The logical conjunction (and) is higher in precedence than the logical negation (not).
C) The comparison operators (==, !=, , =) are higher in precedence than the assignment operator (=).
D) The addition and subtraction operators (+, -) are lower in precedence than the logical conjunction operator (and).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
49
What part of the loop comprises the statements to be executed?

A) The loop header.
B) The loop body.
C) The loop end.
D) The loop tail.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
50
What is a count controlled loop?

A) It is a loop that counts iterations until a sentinel value is received.
B) It is a loop that continues based on a certain time interval.
C) It is a loop that prints out a count of values for the user.
D) It is a loop that counts through a range of numbers to control when the loop ends.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.