A loop in which the condition is always tested at the top of the loop.
What is a pre-test loop?
s[2] if s = "computer science"
What is "m"?
The output of the following code:
x = 5
y = 6
if x*y >= 0:
print("yes")
else:
print("no")
What is "yes"?
A for loop is an indefinite loop.
What is false?
Compiler or interpreter: Tends to produce code that runs faster.
What is a compiler?
A value that can be assigned and re-assigned over and over again.
What is a variable?
my_string[-2:] if my_string = "Saint Mary's".
What is "'s"?
The output of the following code:
n = -7
if abs(n) <= 4:
if n > 0:
print(2*n+1)
else:
print(2*n)
else:
print(n, "out of range")
What is "-7 out of range"?
The output of:
for i in range(5):
print(i, end=" ")
What is "0 1 2 3 4 "?
Binary number 10 in decimal notation.
What is 2?
A combination of literals, variables, calls to functions, and operators that produce a value.
What is an expression?
"".join(["a", "b", "c"])
What is "abc"?
The output of the following code:
n1, n2, n3 = 1, 2, 3
if n2 > n3:
print("one")
elif n3 >= n1:
print("two")
else:
print("three")
What is "two"?
The output of the following code:
for i in range(12, 3, -3):
print(i//3)
What is the following?
4
3
2
"Create a design" is the third step in the software development process.
What is true?
1. Analyze the problem
2. Determine specifications
3. Create a design
4. Implement the design (program)
5. Test/debug the program
6. Maintain the program
An operation that creates an object.
What is a constructor?
chars[4 + (pos + 1) % 4] if pos = 3 and chars = "ABCDabcd".
What is "a"?
The output of the following code:
x = 5
if x >= 0:
print(1)
elif x < 20:
print(2)
else:
print(3)
What is "1"?
The output of the following code:
again = True
number = 0
while again:
print(number//2)
number += 2
if number == 8:
again = False
What is the following?
0
1
2
3
The methods index, pop, and split are all list methods.
What is false? (The split method is a string method.)
A loop that allows the user to repeat the loop on demand.
What is an interactive loop?
word.append("!") if word = "hi".
What is an (attribute) error? (The append method is a list method, not a string method.)
a, b = 7, 15
if a != 1:
b = 4
a = 30
else:
a = 5
b = 10
b = b//a
print(a, b)
What is "30 0"?
The output of the following code:
i = 2
while i > 0:
print(i, end=" ")
i -= 1
What is "2 1 "?
Hexadecimal number 0x4A in binary notation.
What is 1001010?