new study guide solution Wilfrid Laurier University
CP104 Introduction to Programming Mid Term Review Questions
Part 1 – True/False Questions
a. In Python, print statements written on separate lines do not
necessarily output on separate lines. F
b. The \t escape character causes the output to skip over to the next
horizontal tab.T
c. Since a named constant is just a variable, it can change any time during
a program's execution.F
d. In Python, math expressions are always evaluated from left to right, no
matter what the operators are. F
e. According to the behavior of integer division, when an integer is divided by
an integer, the result will be a float. F
f. Computer programs typically perform three steps: input is received,
some process is performed on the input, and output is produced. T
g. The if statement causes one or more statements to execute only when
a Boolean expression is true. T
h. The following code snippet will change the turtle's pen size to 4 if it is
presently less than 4: T
i. if turtle.pensize() < 4:
j. turtle.pensize(4)
k. Both of the following for clauses would generate the same number of loop
iterations. T
for num in range(4):
for num in range(1, 5):
,l. To get the total number of iterations in a nested loop, add the number of
iterations in the inner loop to the number in the outer loop. F
m. A while loop is called a pretest loop because the condition is tested after
the loop has had one iteration. F
, n. A function definition specifies what a function does and causes the
function to execute. F
o. Python allows you to pass multiple arguments to a function. T
p. A local variable can be accessed from anywhere in the program. F
q. A value-returning function is like a simple function except that when it
finishes it returns a value back to the part of the program that called it. T
Part 2 – Multiple Choice Questions
The function reads a piece of data that has been entered at the
keyboard and returns that piece of data, as a string, back to the program.
a. input()
b. output()
c. eval_input()
d. str_input()
The line continuation character is a
a. #
b. %
c. &
d. \
Which mathematical operator is used to raise 5 to the second power in Python?
a. /
b. **
c. ^
d. ~
In a print statement, you can set the argument to a space or empty string
to stop the output from advancing to a new line.
a. stop
b. end
c. separator