CNIT 155 COMPREHENSIVE 2026 EXAM QUESTIONS AND
SOLUTIONS RATED A+
✔✔Which output will the following code produce?
color = []
color = ["blue", "green", "red"]
print(color[2]) - ✔✔red
✔✔Which of the following will randomize the order of elements in a list sampleList?
Assume that the required library has been imported correctly.
A. sort(sampleList)
B. shuffle(sampleList)
C. random(sampleList)
D. randomize(sampleList) - ✔✔B. shuffle(sampleList)
✔✔list1 = [1, 2, 3, 4]
list2 = [5, 6, 7, 8]
print ( len(list1 + list2) ) - ✔✔8
✔✔Passing a list as an argument passes a copy of the list. T/F - ✔✔False
✔✔Lists are mutable T/F - ✔✔True
✔✔The built-in function split() return a list T/F - ✔✔True
✔✔The index of the first value in a python list is 1 T/F - ✔✔False
✔✔Lists are a type of data structure that can store many values under one name T/F -
✔✔True
✔✔Analyze the following code:
count = 0
while count < 100:
#Point A
print("Welcome to Python!")
count += 1
#Point B
#Point C
A. count < 100 is always True at point c
B. count < 100 is always True at point b
C. All answers are False
D. count < 100 is always True at point A - ✔✔B. count < 100 is always True at point A
, ✔✔While loops are pretest loops T/F - ✔✔True
✔✔In Python, the division operator (/) gives a float result, even if both of the numbers
are integers T/F - ✔✔True
✔✔What is the output of the following code?
n = 20
while (n <= 25):
print(n,"\n")
n = n+1 - ✔✔20,21,22,23,24,25
✔✔If we want score to be a random number in the range of [10.0, 50.0), which
statement would be correct (assuming the random library has been imported)?
A. score = 40.0 * random + 10.0
B. score = 50.0 * random + 10.0
C. score = 10.0 * random + 40.0
D. score = random() + 50.0 - ✔✔A. score = 40.0 * random + 10.0
✔✔The expression 3 ** 3 - (6-2)/2 has the value _____. Is it an integer or a float value?
__________________.
A. 7, int
B. 25, float
C. 7, float
D. 25, int - ✔✔B. 25, float
✔✔Suppose you're given a list of words, intList. Write Python code that will print one
line for each number, repeating that number twice. For example, if intList is [60, 70, 80,
90], then your code would print:
60 60
70 70
80 80
90 90 - ✔✔def main():
intList = [60, 70, 80, 90]
for i in range(0, len(intList)):
print(intList[i], " ", intList[i], "\n")
i += 1
main()
✔✔Write a Python program to check if the letter 'e' is in a given string:
Example:
SOLUTIONS RATED A+
✔✔Which output will the following code produce?
color = []
color = ["blue", "green", "red"]
print(color[2]) - ✔✔red
✔✔Which of the following will randomize the order of elements in a list sampleList?
Assume that the required library has been imported correctly.
A. sort(sampleList)
B. shuffle(sampleList)
C. random(sampleList)
D. randomize(sampleList) - ✔✔B. shuffle(sampleList)
✔✔list1 = [1, 2, 3, 4]
list2 = [5, 6, 7, 8]
print ( len(list1 + list2) ) - ✔✔8
✔✔Passing a list as an argument passes a copy of the list. T/F - ✔✔False
✔✔Lists are mutable T/F - ✔✔True
✔✔The built-in function split() return a list T/F - ✔✔True
✔✔The index of the first value in a python list is 1 T/F - ✔✔False
✔✔Lists are a type of data structure that can store many values under one name T/F -
✔✔True
✔✔Analyze the following code:
count = 0
while count < 100:
#Point A
print("Welcome to Python!")
count += 1
#Point B
#Point C
A. count < 100 is always True at point c
B. count < 100 is always True at point b
C. All answers are False
D. count < 100 is always True at point A - ✔✔B. count < 100 is always True at point A
, ✔✔While loops are pretest loops T/F - ✔✔True
✔✔In Python, the division operator (/) gives a float result, even if both of the numbers
are integers T/F - ✔✔True
✔✔What is the output of the following code?
n = 20
while (n <= 25):
print(n,"\n")
n = n+1 - ✔✔20,21,22,23,24,25
✔✔If we want score to be a random number in the range of [10.0, 50.0), which
statement would be correct (assuming the random library has been imported)?
A. score = 40.0 * random + 10.0
B. score = 50.0 * random + 10.0
C. score = 10.0 * random + 40.0
D. score = random() + 50.0 - ✔✔A. score = 40.0 * random + 10.0
✔✔The expression 3 ** 3 - (6-2)/2 has the value _____. Is it an integer or a float value?
__________________.
A. 7, int
B. 25, float
C. 7, float
D. 25, int - ✔✔B. 25, float
✔✔Suppose you're given a list of words, intList. Write Python code that will print one
line for each number, repeating that number twice. For example, if intList is [60, 70, 80,
90], then your code would print:
60 60
70 70
80 80
90 90 - ✔✔def main():
intList = [60, 70, 80, 90]
for i in range(0, len(intList)):
print(intList[i], " ", intList[i], "\n")
i += 1
main()
✔✔Write a Python program to check if the letter 'e' is in a given string:
Example: