UniSA STEM
TEST
COMP1039 Problem Solving and Programming
This paper is for Mawson Lakes and Mawson Lakes (External) students.
IMPORTANT:
THIS IS NOT THE TEST. There is no guarantee that these questions will appear in the
test. You need to study all the material covered during the study period (i.e. in
workshops, practical and assignment work. This SAMPLE TEST is provided in order to
give you practice in test style questions only. This is a good indication of the style and
type of questions you are likely to get in the actual test.
Test Duration: 120 minutes
Reading Time: 10 minutes For Examiner Use Only
Question Mark
1
2
3
4
5
6
7
Materials Permitted In The Test Venue:
(No electronic aids are permitted e.g. laptops, phones) 8
Open Book - No restriction.
Total ________
Materials To Be Supplied To Students:
None.
Instructions To Students:
Write your student number and full name in BLOCK letters in the space above.
The test is worth a total of ## marks. You are required to answer all questions.
Write your answers in this test booklet, which must be handed up. Spare pages are included at the back
for you to continue answers to questions if necessary.
Do not remove any pages from this booklet.
Answer each question precisely. Do exactly what the question asks, and nothing more.
1 of 18
,QUESTION 1 [25 marks]
What output does the following code produce?
Code Output
a)
k = 0
theList = ['eight', 'seven', 'two']
while k <= 2:
print(theList[k])
k = k + 1
[2 marks]
b)
k = 0
while k < 8:
if k % 2 == 0:
print('in da loop')
k = k + 1
[2 marks]
c)
k = 0
while k < 10:
k = k + 2
print(k)
[2 marks]
d)
x = 2
y = 7
z = 2
for k in range(x, y, z):
print('hello')
[3 marks]
2 of 18
, Code Output
e)
line = 'abcdef'
count = [3,4,7,1,2,5]
index = 0
while index < len(line):
print(count[index], end=' ')
for k in range(0,count[index]):
print(line[index],end='')
print()
index = index + 1
[3 marks]
f)
def does_something1(info):
return info[0]
def does_something2(info):
info = info.upper()
return info
info = 'apple'
result1 = does_something1(info)
result2 = does_something2(info)
print('Result is: ', result1)
for stuff in result2:
print(stuff)
[4 marks]
g)
aString = 'This is question thirteen.'
for k in range(8,13):
print(aString[k])
[3 marks]
3 of 18