0% found this document useful (0 votes)
30 views2 pages

Python 2024

Uploaded by

sharlynenyaboke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views2 pages

Python 2024

Uploaded by

sharlynenyaboke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

UNIVERSITY EXAMINATIONS: 2023/2024

EXAMINATION FOR DEGREE IN BACHELOR OF SCIENCE SOFTWARE


DEVELOPMENT/INFORMATION SECURITY AND FORENSIC.
BSD 2302/ BISF 3106: PYTHON PROGRAMMING
MODE: FULL TIME/PART TIME/DISTANCE LEARNING
ORDINARY EXAMINATIONS
DATE: APRIL 2024 TIME: 2 HOURS

INSTRUCTIONS: Answer Question One and Any Other Two.

QUESTION ONE [20 MARKS] COMPULSORY


a) Describe SIX different categories of operators you can use in a python language. [6 Marks]
b) Design a simple program using a flowchart to read number of lessons attended by a student then
convert them to percentage (%) and display remark for a qualification to sit for final examination
using the criteria below:
% of class attendance Remark
Less than 30% Disallowed
30% to 60% Seek permission from registrar
Above 60% Ok to obtain exam card
[6 Marks]
c) Write a python program that prompts user to enter length and width of a rectangle using dialog
boxes then display the length, width and area of the rectangle on a text file whose path is given as
“C:/Users/Calculation”. [8 Marks]

QUESTION TWO [15 MARKS]


In python, a dictionary is a collection of unordered mutable elements and their keys enclosed by {}. In
view of this you are required to write a python program:
a) To read a finite number of product names and their corresponding prices then store them in a
dictionary . [3 Marks]
b) To display all the keys of the dictionary in a). [3 Marks]
c) To display all the values in the dictionary created in a). [3 Marks]
d) To display the price of the product named “sugar” if it is in the dictionary or display “product not
found” otherwise. [6 Marks]

QUESTION THREE [15 MARKS]


You are required to come up with python program that uses two functions. The first function reads the
length and width of a right angled triangle then pass the values to another function that calculates the
hypotenuse. Recall that 𝑎2 + 𝑏 2 = 𝑐 2 , where length, width and hypotenuse are denoted by a, b and c
respectively.
a) Develop a pseudo code (algorithm) to solve this problem. [7 Marks]
b) Write python code to implement the pseudo code above. [8 Marks]

QUESTION FOUR [15 MARKS]


The school of technology has requested you to come up with an e-voting app for student
representation. Assume there are three candidates A, B and C.
a) Write an algorithm that: allows voters to enter either A, B or C. Keeps track of how many times
each candidate has been voted for. As soon as one person has finished voting, allows the next
person to vote. At any point allows the official to type in “END”, which will print out the
number of votes for each candidate and the total number of votes overall. [9 Marks]
b) Write a python program and make use of tkinter module to implement the design in a).
[6 Marks]

You might also like