Exam 3: Control Structures
Exam 1: Introduction102 Questions
Exam 2: Data and Expressions71 Questions
Exam 3: Control Structures129 Questions
Exam 4: Lists85 Questions
Exam 5: Functions83 Questions
Exam 6: Objects and Their Use54 Questions
Exam 7: Modular Design62 Questions
Exam 8: Text Files58 Questions
Exam 9: Dictionaries and Sets33 Questions
Exam 10: Object-Oriented Programming81 Questions
Exam 11: Recursion27 Questions
Select questions type
If statements always make use of a Boolean expression.
Free
(True/False)
4.8/5
(40)
Correct Answer:
True
Rewrite the following program code with proper indentation.
if num > 100:
print('invalid value')
else:
if num > 50:
print('high value')
else:
print('low value')
Free
(Essay)
4.8/5
(36)
Correct Answer:
if num > 100:
print('invalid value')
else:
if num > 50:
print('high value')
else:
print('low value')
A Boolean expression is an expression that evaluates to True or False.
Free
(True/False)
4.8/5
(34)
Correct Answer:
True
Match the descriptions with their terms:
-based on a condition that may be checked many times
(Multiple Choice)
4.8/5
(34)
not (flag1 or flag2) is logically equivalent to (not flag1) and (not flag2), where flag1 and flag2 are Boolean values.
(True/False)
4.8/5
(43)
num1 <= num2 is logically equivalent to not (num1 > num2), where num1 and num2 each contain an integer value.
(True/False)
4.9/5
(33)
What is the term for a program that does not have any control flow, other than sequential control?
(Short Answer)
4.8/5
(34)
Match the expressions that they are logically equivalent to the Boolean expressions :
-not (x == y)
(Multiple Choice)
4.8/5
(35)
The three forms of control provided by programming languages are ________________,__________, and __________________ control.
(Short Answer)
4.7/5
(37)
Examine the following lines of code:
Current = 1
Sum = 0
N = 5
While current <= n:
Sum = sum + current
Current = current + 1
This is an example of:
(Multiple Choice)
4.9/5
(39)
In Python, indentation is not significant. It is simply a strict convention used for readability and considered good programming etiquette.
(True/False)
4.9/5
(33)
Give Python code that prompts the user to enter positive integer values, and continues to prompt the user until a value of -1 is entered, adding up all the value entered and displaying the result.
(Essay)
4.8/5
(44)
Which of the following can the condition of an if statement be based on?
(Multiple Choice)
4.7/5
(38)
For a variable named num with an integer value, give an if statement that displays "valid value" only if the value of num is between 1 and 100, inclusive.
(Short Answer)
4.9/5
(40)
Match the expressions that they are logically equivalent to the Boolean expressions :
-not (x > y)
(Multiple Choice)
4.9/5
(40)
In order to construct an if statement that performs multiway selection between three or more sets of instructions (suites), the _______ header must be used.
(Short Answer)
4.9/5
(30)
A boolean flag is a variable with either a True or False value indicating whether a given event has occurred or not.
(True/False)
4.8/5
(36)
Examine the following expression:
10 < 20 and 30 > 50
What does this expression evaluate to?
(Multiple Choice)
4.7/5
(39)
Showing 1 - 20 of 129
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)