Professional Documents
Culture Documents
Lab Assessment 2
Instructions: Please carefully read the Question and code a suitable solution in Eclipse. This
is a closed book examination so no use of internet or any other material. You can only open
eclipse in your computer.
Referencing: Please reference any work cited. Use Harvard Referencing Style. Remember
that Plagiarism will lead to disciplinary action under the University of Fiji Regulation
“Plagiarism and Dishonest Practice”.
Marking Criteria: Marks will be allocated for preciseness of output and correctness of
syntax. In addition, the quality and the authenticity of explanations will be considered.
Submission: The solutions of each question much be correctly labelled and uploaded with a
brief description of the code used to implement the solutions. Students will need to upload
the answers in a word file in the given Turnitin Submission box on Moodle.
Weight: 10%
QUESTION 1
Create a python program that takes in an array (a) and returns True if all elements in the array
are unique. The program should return False if the array contains duplicate elements and it
should also list the values which are duplicates.
a = [1 , 20, 30, 14, 55 , 19, 16, 78, 45, 16, 87, 98, 71, 14, 21, 32, 66, 83, 85, 91, 22, 11]
Expected output
Are the values in the array unique? False
Which calues are duplicates? 16, 14
def check_duplicates(a):
return len(set(a)) == len(a), [x for x in set(a) if a.count(x) > 1]
QUESTION 2
Create a python program that checks whether two(2) lists a and b are premutations of each
other. For example if a[1,2,3] and b[3,2,1] are premutations of each other as both have the
same values in the array.
a = [1, 2, 3]
b = [3, 1, 2]
Expected output
True
a = [1, 2, 3]
b = [3, 2, 4]
Expected output
False
QUESTION 3
1 2 3 90 degrees 7 4 1
4 5 6 8 5 2
rotation
7 8 9 9 6 3
Good Luck