CMPSC 101 MIDTERM 1 EXAM 2025
BRAND NEW ACTUAL EXAM WITH 100%
VERIFIED QUESTIONS AND CORRECT
SOLUTIONS| ACE YOUR GRADES.
Comments are lines that might appear in a program, beginning
with a # (and appearing in red in IDLE).
For best results, when should these be placed into the program...
- correct answer -As the very first thing, to provide structure when
coding, and explanation afterwards
Predict the results of the following code:
a=3
, Page | 2
b=a
a=4
b = b+4
print(b) - correct answer -7, adding 4 to the 3 b received before
What is the actual result of these statements in Python?
vec1 = [ 1, 2, 3 ]
vec2 = [ 0, -1, 1 ]
vec1 + vec2 - correct answer -[1, 2, 3, 0, -1, 1]
vec1 = [ 1, 2, 3 ]
2 * vec1
is the same as - correct answer -vec1 + vec1
A list element can be retrieved based on its position using -
correct answer -the [] operation.
Do mylist[number] and mylist.index(number) mean the same
thing? - correct answer -No -- they are very different, and would
only be equal by coincidence in the data