100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

UniSA STEM TEST COMP1039 Problem Solving and Programming

Rating
-
Sold
-
Pages
18
Grade
A+
Uploaded on
26-10-2021
Written in
2021/2022

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 Materials Permitted In The Test Venue: (No electronic aids are permitted e.g. laptops, phones) Open Book - No restriction. 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. For Examiner Use Only Question Mark 1 2 3 4 5 6 7 8 Total ________ 2 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] 3 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 = () 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] 4 of 18 Code Output h) def question15(no1, no2, no3, no4): res = no1 + no2 res = res - no3 res = res + no4 return res no1 = 5 no2 = 1 print('Here it is: ', question15(no1, no2, no1, no2)) [3 marks] i) nums = [1, 5, 1, 1, 3, 1, 4] k = 0 while k < len(nums): if nums[k] == 1: print('found one') k = k + 1 [3 marks] j) num1 = 1 num2 = 2 num3 = 3 res = 0 num2 += 6 res = num1 + num2 - 2 res = res + num1 * 2 num3 = num1 + num1 // num2 res = res - num3 num1 = num2 res = res + num1 print(res, num3, num2, num1) [4 marks] 5 of 18 k) def another_function(): result = 0 for num in range(2, 7): result = result + num print(num, end=' ') return result res = another_function() print(res) [4 marks] 6 of 18 QUESTION 2 [40 marks] a) What output does the following code produce? [8 marks] def function1(): global j j = 1 k = 2 print('j is:', j, 'k is', k) def function2(j, k): j = 8 k = 7 print('j is:', j, 'k is', k) def function3(): print('j is:', j, 'k is', k) def function4(): function3() j = 300 j = 'one' k = 'two' function1() print('j is:', j, 'k is', k) function2(j,k) print('j is:', j, 'k is', k) function4() print('j is:', j, 'k is', k) k = 'three' function1() print('j is:', j, 'k is', k) Write your answer here: 7 of 18 QUESTION 2 continued… b) What output does the following code produce? [10 marks] def does_suppin(my_list): for letter in my_list: print(letter, end="") print() list1 = [2.5, 3, 7.0, 10.5, 4, 9.0] index = 0 total = 0 while index < len(list1): total = total + list1[index] index += 1 print("First value:", total) print("Second value:", index) result = total / index print("The result is:", result) for num in list1: if num % 2 == 0: print(num, "is even") if num < result: print(num, "is less than the average of", result) list2 = ['s', 'e', 'e', 'd'] does_suppin(list2) list2[0] = 'f' does_suppin(list2) string1 = "this is a test" index = 0 while index < len(string1): if index % 2 == 0: print(string1[index], end=" ") index += 1 Write your answer here: 8 of 18 QUESTION 2 continued… c) Given the following input file called "": The input file contains the following: elvis has left the building! What output does the following code produce?

Show more Read less
Institution
Module










Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Module

Document information

Uploaded on
October 26, 2021
Number of pages
18
Written in
2021/2022
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

SAMPLE Test




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

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Themanehoppe American Intercontinental University Online
Follow You need to be logged in order to follow users or courses
Sold
292
Member since
4 year
Number of followers
223
Documents
3485
Last sold
3 months ago

3.4

48 reviews

5
21
4
5
3
7
2
3
1
12

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Frequently asked questions