0% found this document useful (0 votes)
7 views4 pages

Sample Questions Python Control Structures

The document outlines various payroll and student management tasks to be automated using Python programs. It includes calculations for PAYE tax rates, gross pay, net pay, student grading based on marks, vehicle availability based on destination and time, lecture hall scheduling, employee information management, and wage calculations for a company. Each task specifies the required input and expected output, along with the logic to be implemented in the Python programs.

Uploaded by

wanderajesse886
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)
7 views4 pages

Sample Questions Python Control Structures

The document outlines various payroll and student management tasks to be automated using Python programs. It includes calculations for PAYE tax rates, gross pay, net pay, student grading based on marks, vehicle availability based on destination and time, lecture hall scheduling, employee information management, and wage calculations for a company. Each task specifies the required input and expected output, along with the logic to be implemented in the Python programs.

Uploaded by

wanderajesse886
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

1.

Safaricom Company Ltd uses the following PAYE (Pay As You Earn) percentage
tax rates for all its employees’ salary categories
Gross Salary (Kshs.) PAYE rate (%)
50,001 and above 14

40,000 – 49,999 12

35,000 – 39,999 11

25,000 – 34,999 8

16,000 – 24,999 5

9,500 – 15,999 3

Below 9500 0

The following standard deductions apply to all employees

N.S.S.F = Ksh. 80.00

N.H.I.F = Ksh. 200.00

Service charge = Ksh. 100.00

The overtime rate is Kshs. 300 per hour for the first 50 hours an employee has
worked overtime. Any extra overtime hour is paid at Kshs. 350

At the end of the month, the payroll clerk runs a payroll through which he enters
each employee’s basic salary into the computer and overtime hours worked as
recorded in a claim form filled by the employee.

The computer in turn adds up the basic salary and the overtime pay (if any) to
get the gross pay. The computer then determines the PAYE amount payable from
the gross pay.

Finally, the employee’s net pay is calculated using the formula:

Net Pay = Gross pay – [PAYE + (N.S.S.F + N.H.I.F + Service charge)]

Required:
Write a python program that performs the above-mentioned payroll activities for
a single employee and outputs Gross Pay, PAYE Amount and Net Pay on the
screen

2. Write a python program that accepts registration number, name, gender, unit
name and unit code and marks of a student for that unit. Based on the marks of
the student, the program should calculate the grade and corresponding comments
based on the following grading criteria. If the marks are invalid, i.e., below 0 and
more than 100, the program should output an error and prompt the use to enter
the marks again. If the marks are correct, the program should display the
transcript of the student. Use the following grading criteria for your program.
Marks Grade Comments

Between 70 and 100 A Excellent

Between 60 and 69 B Good

Between 50 and 59 C Fair

Between 40 and 49 D Pass

Between 0 and 39 F Fail

3. Write a python program that is supposed to return available vehicles based


on destination and time passengers are travelling. If there are vehicles
travelling at that destination and time, the program should display the
information in a tabular format else the program should display appropriate
error message. Use if statements to make your decisions
Regno Departure time Destination name Arrival date

KBZ 009z 11:00 Voi 12:00

KBX 100x 9:00 Kisumu 12:00

KAQ 998y 8:00 Mombasa 2:00


4. Write a python program which allows users to enter the lecture hall, time slot
and day. Depending on the three parameters, the program should inform the
user if the resource is free or not. If the resource is not free, the program
should print the details of the unit and lecturer on else it should display the
message “Resource is not free”. You may usthe following table to make your
decisions. Use if…elif statements to make program decisions
hall Unit name Lecturer Time slot Day

TH lab A Database Systems Joe 11:00-2:00 Tuesday

TH Lab A Operating Systems Phil 2:00-5:00 Wednesday

TH Lab B Logic Programming Christiana 11:00-2:00 Friday

5. The following problem definition relates to XYZ Company. Once a new


employee is hired in the organization, his/her information is captured and a
new file opened for that employee. This information includes his name, gender
and his/her job grade.

Based on the employee qualifications, the HR department allocates the new


employee a job grade. The job grade determines the employee basic salary,
housing and travelling allowance. Based on the three, the organization can
computer his/her gross salary i.e., salary before tax.
The following are the current job grade for the organization
Job grade Basic salary House allowance House
allowance
H 12000 2000 3000
M 18000
S 60000 40000 12000
Required
As a Python programmer you are required to automate the above business
logic by writing the appropriate python code
6. A program is required to calculate wages for employees of Kamonjo Ltd.

using the following formulae

i) Basic salary = No of Hours * hourly rate

ii) Hourly rate=Kshs. 850

iii) Lunch Allowance = Kshs. 200.00

iv) Gross Salary = Basic Pay + Lunch Allowance

v) Income Tax charged on gross pay as follows:

Gross Tax

0-1999 0%

2000-2999 5%

3000-3999 7%

4000-4999 9%

5000 and above 11%

v) Net pay = Gross pay – Tax

Write a Python program that implement the above business logic.

You might also like