Sample Exam Paper
Sample Exam Paper
1) This exam consists of 5 questions worth 100 marks. Attempt all questions.
2) You must submit a single zip file to the LMS on or before the deadline. The zip file must
contain the PDF file "ict582-exam.pdf" and all Python program files required by each
question (note: only zip file is accepted. No other compression formats will be accepted).
4) The file "ict582-exam.pdf" must contain your answers to all questions including the
Python program for each question.
4) You must type your full name and student number at the beginning of the file "ict582-
exam.pdf".
5) In file "ict582-exam.pdf", your answer to each question must start with a line "Question i"
where "i" is the question number, such as "Question 2".
6) To increase the success rate of plagiarism detection, you must not copy the question itself
to file "ict582-exam.pdf" or to any Python program. Submissions from all students will be
rigorously checked by computer software as well as manually to detect any form of
plagiarism.
7) You can access all teaching materials of the unit during the exam, including the textbook,
lecture notes, lab sheets, and the assignment questions, as well as your solutions to the lab
exercises and the assignment.
8) You can also access the Internet for any public resources, particularly for information on
the definition and use of standard Python functions and Python modules. But you are not
allowed to copy and paste any material from the Internet. Copying from any Internet source
and pasting it to your answer (unless asked) can lead to no marks being awarded.
9) You are not permitted to communicate with anyone (except staff from the Exam Office)
regarding the exam questions during the exam.
10) To ensure no ghost-writing occurs during the exam, I may ask some of you for an
interview to discuss the solutions you have submitted.
Question 1 (20 marks)
b) [7 marks] Define and critically discuss the concepts of Abstraction and Decomposition.
Write a Python program that reads a string from the keyboard. The program should then
a) [10 marks] Create a new string that contains all vowel characters (a,e,i,o,u,A,E,I,O,U)
from the input string in the order of their appearance in the original input string. This new
string should not contain any other characters. Print out the new string.
b) [10 marks] Count and report the number of occurrences of each vowel character in either
the original input string or in the new string. When counting the vowel characters, ignore
the case, i.e., treat the lower and upper case of a letter as the same letter (e.g., the
character ‘a’ and ‘A’ are considered to be the same character when counting the number
of occurrence).
a) [7 marks] Explain what a sequence is in Python and give 5 sequence data types you have
learned in ICT582 and list the similarities of these sequence data types.
b) [3 marks] Write a Python function named find, which takes a string and a character as
its parameters and returns True if the character is found in the string; otherwise, it returns
False. Write a small code to test this function.
c) [2 marks] Write a Python function named find, which takes a list and a value as its
parameters and returns True if the value is found in the list; otherwise, it returns False.
Write a small code to test this function.
d) [8 marks] Depending on how you implemented the two functions in 3b) and 3c), you may
notice that the structures of these two functions can be very similar or even identical with
each other. Write a Python function named find, which takes two parameters: the first
parameter represents a sequence, and the second parameter represents an item in the
sequence. The function returns True if the second parameter (the item) is found in the first
parameter (the sequence). Otherwise, it returns False. Write a small code to test this
function using a string, a list, and an ndarray as the sequence respectively.
Question 4 (20 marks)
a) [5 marks] Explain the relationship and difference between a class and its objects.
b) [10 marks] Define a class to represent a student, with the following data attributes:
• name
• age
• major
The class also has a method display that prints out the information about the student,
in the following format (as an example):
Name: John
Age: 25
Major: Information Technology
Apart from the above data attributes and method, the class must have appropriate
__init__ method(s) that facilitate the creation of objects.
c) [2 marks] Create a student object with the following details: his name is John, aged 25,
majoring in Information Technology. Display the information of the object using its
display method.
d) [3 marks] Create another student object with the information: Emma, 23, Information
Systems. Display its information via the object.
Change the major of the student from Information Systems to Computer Science and then
display the new information via the same object.
A company stores its sales records in a CSV file, which contains a list of sales to its
customers. The file has the following columns, date (the date of the sale), name (the name
of the customer), value (the value of the sale). The following is a sample of the file content:
Date,Name,Value
12/6/2021,John Smith,20000
9/3/2022,Jan Doe,30980
10/3/2022,Garry Martin,7800
3/4/2022,Carmel Tebbutt,31400
Write a Python program that prompts the user to enter the name of the CSV file and then
calculate the total sales (the sum of all sale values). It then prints out the total sale value and
the name of the customer to whom the highest valued sale was made.
END OF QUESTIONS