ENGG1003 - Lab09 - PythonDataProcessing 3
ENGG1003 - Lab09 - PythonDataProcessing 3
You that
areand
➢Iacknowledged,
declare welcome
the seeking
lab work here help
submitted is at IT Clinic
original except (HCA 328)
for source during
material explicitly
that the same or closely related material has not been previously submitted for
office hours.
another course.
I also acknowledge that I am aware of University policy and regulations on honesty in academic
work, and of the disciplinary guidelines and procedures applicable to breaches of such policy and
regulations, as contained in the website.
•
Python function recap
def sayHi():
Define the function first
print("Hi!")
➢ Add some code to get some user input, test and check the result
➢ We shall use input("...") statement to ask for total hours of work that is
a float type value.
return total_Weekly_Wage
# Output
print(f'Wages for {totalHours} hours at ${hourlyWage} per hour
are ${total_Weekly_Wage}')
Task 1 – Check your output
Inputs Outputs
hourlyWage FIXED in TASK 1 totalHours total_Weekly_Wage
(will change in TASKS 3 and 4) calcWeeklyWage( )
55 40 $2200.0
55 30 $1650.0
55 28.5 $1567.5
➢ Completion Reminder:
➢ After completing task 1, save your work in “employeeWage.py”
➢ Make sure the “employeeWage.py” file has complete code of task 1.
Task 2
Task 2 Scenario
➢ Let us now assume that every employee of CUHK
supermarket work for 40 hours/week as a standard.
# Assume
hourlyWage = 55
# Input
totalHours = # Keep the statement you have created in task 1
# Process
# KEEP Your function call for TASK 1
# Call the function for TASK 2.
Type here to call the calcWithOverTimeWage( ___ , ___ ) function
total_Weekly_Wage =
# Output
print(f'Wages for {totalHours} hours at ${hourlyWage} per hour are
${total_Weekly_Wage}')
Task 2 – Check your output
Inputs Outputs
hourlyWage FIXED in TASKS 1 and totalHours total_Weekly_Wage
2 calcWithOverTimeWage()
(will change in TASKS 3 and 4)
55 39.5 $2172.5
55 50 $3025.0
55 45 $2612.5
➢ Completion Reminder:
➢ After completing task 2, save your work in “employeeWage.py”
➢ Make sure the “employeeWage.py” file contains complete
code for task 2 calcWithOverTimeWage( ) and
code for task 1 calcWeeklyWage( ).
Task 3
Task 3 Scenario
➢ Let us now assume now, that there are three pay scales in
CUHK supermarket.
➢ Their total number of working hours in a week and the scale
point list are given in the table.
Employee Total worked hours Pay Scale Pay Scale Hourly Wage
A 42 3 3 80
B 38.5 2 2 70
C 45 1 1 55
employee.
Pass the
➢ Finally, by using hourly wage parameters
if payScale equals 3:
hourlyWage shall be 80
elif payScale equals 2:
hourlyWage shall be 70 Use if-elif statements and set
: hourly wage for the
:
corresponding pay scale
else: information according to
hourlyWage shall be -1 table in slide 22
print("Invalid data")
# Output
print(f'Wages for {totalHours} hours at ${hourlyWage} per hour are
Task 3 – Check your output
and Submit
Inputs Outputs
➢ Submission Details:
➢ After completing task 3, save your work and submit the completed
“employeeWage.py” file on Blackboard
➢ Please note: Make sure the completed “employeeWage.py” file has
complete codes of tasks 1, 2 and 3.
Bonus Task 4
Task 4 Scenario
➢ In this task we introduce 4 employee roles with various pay scale.
➢ You are required to map the employee role to the pay scale, thus hourly
wage.
➢ Pay scale and hourly wage information are shown in the table below:
CUHK Supermarket Scale Point List (Same as TASK 3)
Employee role Pay scale Pay Scale Hourly Wage
manager 3 3 80
supervisor 2 2 70
accountant 1 1 55
worker 1
➢ Observe that "accountant" and "worker" have the same pay scale.
That means same pay scale can be assigned to more than one
employee roles.
➢ OT and all previous wage calculations shall be taken into account.
Bonus Task 4 Scenario
➢ If you attempt Bonus Task 4, you shall surrender part of your work in Task 3!!
➢ Your program asks the user for these inputs:
➢ number of hours worked in a week, keep the same line as in Tasks 1, 2 and 3
➢
Loading…
Create a new function named roleWage( ) that takes two arguments,
totalHours and employeeRole.
➢ Argument employeeRole is expected to be a single word in lower-case:
manager or supervisor or accountant or worker
➢ This function calls scaleWage() function to obtain and return end results
Ø During Input and Testing, we shall convert the user input to lower-case
Ø E.g., name = "PeTer".lower() name will be "peter"
Step 3 Step 2
Step 6 Step 7
Pass the
Step 5 Return Pass the parameters
Step 4
result parameters
Step 1
calcWeeklyWage() # Process
- Request parameters
Step 8 is a line already given at the end, for ALL TASKS - Call the function
Print and check the result
Task 4 FOLLOWS Task 3
➢ Based on your COMPLETED work in file “employeeWage.py” that
contains all the complete codes of Tasks 1, 2 and 3.
➢ Read the Comments/TODO in the file and work on the Bonus Task
4 in the SAME file “employeeWage.py"
➢ Construct the roleWage() function that accepts the employee role
to determine the scale point and total weekly wage.
➢ Then, calculate the weekly wage of an employee by calling some
existing function. The expected output is shown in table below:
Inputs Outputs
totalHours employeeRole total_Weekly_Wage
37 manager $2960.0
41 supervisor $2905.0
45 accountant $2612.5
45 worker $2612.5
Bonus Task 4 - Submission