The Co-operative University of Kenya
SPECIAL / SUPPLEMENTARY EXAMINATION AUGUST -2022
EXAMINATION FOR THE DEGREE OF BACHELOR OF INFORMATION
TECHNOLOGY / BACHELOR OF SCIENCE IN STATISTICS & INFORMATION
TECHNOLOGY (YR I SEM II)
UNIT CODE: BCIT 2115
UNIT TITLE: PYTHON PROGRAMMING
DATE: 1st AUGUST, 2022 TIME: 9:00 AM – 11:00 AM
INSTRUCTIONS:
Answer question ONE (compulsory) and any other TWO questions
QUESTION ONE
(a) With illustrations, List FIVE data types used in Python (5 Marks)
(b) With the use of illustrations, highlight the reasons why we might use pseudo code to write
an algorithm. (4 Marks)
(c) With examples/illustrations, differentiate between a constructor and a method. (4 Marks)
(d) Consider student class containing data fields: Student ID, first name, last name, course, and
phone number. It also has two functions: enter details and display details. Show how the
above class can be declared. (6 Marks)
(e) Using a loop of your choice, write a program that displays numbers from 1 to 20 in a
vertical format. (4 Marks)
(f) Debugging is an important element in python programming
i. Discuss the term debugging (3 Marks)
ii. Describe how debugging approached in a python programming environment
(4 Marks)
QUESTION TWO
You are provided with the following student grades for 5 students
Student ID 101 102 103 104 105
CAT mark 20 49 51 70 10
Exam 33 50 69 0 80
Assumptions
CAT marks are worth 40% of the overall mark
Exam marks are worth 60% of the overall mark
Pass mark is 50% and above
Write a python program to:
(a) Produce a list of all the students who have passed (7 Marks)
The Co-operative University Of Kenya – August, 2022 1
(b) Produce a separate list of Student Ids for those students who failed (7 Marks)
(c) Generate the Student Id of the student who should get the module prize (the student with the
highest overall mark). (6 Marks)
QUESTION THREE
(a) Give any THREE reasons for using functions in Python Programming? (3 Marks)
(b) Write a Python program to create a function that takes the length (l), width (w) and height
(h) of a three-dimensional shape as arguments then returns the volume of the shape by
multiplying them together (l * w * h). (5 Marks)
(c) Explain TWO ways of achieving polymorphism in Python Programming. (4 Marks)
(d) Write a Python program that demonstrates polymorphism (8 Marks)
QUESTION FOUR
(a) Using examples explain two iteration structures in Python (6 Marks)
(b) Highlight two methods of handling comments in Python (6 Marks)
(c) Write python code for a form that receives two variables id and names and print that which
prints them in a file [Link] (8 Marks)
QUESTION FIVE
(a) Explain any THREE types of inheritance used in Python (6 Marks)
(b) What is the difference between Data abstraction and data encapsulation? (4 Marks)
(c) With the aid of examples, distinguish between global variables and local variables (5 Marks)
(d) Use for loops to construct a program that displays a pyramid of Xs on the screen. The
pyramid should appear as below (5 Marks)
XXX
XXXXX
XXXXXXX
XXXXXXXXX
The Co-operative University Of Kenya – August, 2022 2