0% found this document useful (0 votes)
4 views83 pages

Automating HR Bonuses with Python

Ananya, the HR Manager at GlobalBiz Ltd., faced inefficiencies in manually calculating employee bonuses using Excel, leading her to explore Python for automation. With the help of an intern, Dev, she implemented a system that streamlined the eligibility process through various Python concepts such as variables, loops, and functions. The result was a scalable, efficient, and auditable solution that empowered Ananya to manage HR logic independently.

Uploaded by

arjunkrishna.o
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)
4 views83 pages

Automating HR Bonuses with Python

Ananya, the HR Manager at GlobalBiz Ltd., faced inefficiencies in manually calculating employee bonuses using Excel, leading her to explore Python for automation. With the help of an intern, Dev, she implemented a system that streamlined the eligibility process through various Python concepts such as variables, loops, and functions. The result was a scalable, efficient, and auditable solution that empowered Ananya to manage HR logic independently.

Uploaded by

arjunkrishna.o
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

Python Basics

for Business
Users
Module 1
Dr. [Link] (CL)
Mr. Shankar Raman R (CC)
Gowri J (TA)
Bonus Bot: An HR Manager’s Journey
Context (Background)
Ananya is the HR Manager at GlobalBiz Ltd., a mid-sized Indian company with over 200
employees across departments. Each quarter, she is tasked with identifying employees
eligible for a performance bonus based on:
More than 2 years of experience, and
Sales exceeding ₹50,000
Though the rule is simple, executing it manually via spreadsheets was inefficient,
time-consuming, and prone to human error. With growing teams and frequent
policy changes, Ananya began exploring digital solutions.
The Problem

•Bonus decisions were manually computed using


Excel filters and formulas

•Repetitive logic and rule changes made the process


brittle

•There was no proper record of who got bonuses


and why

•The HR team lacked technical expertise but needed


a scalable, no-cost automation tool
• A young intern, Dev, suggested
using Python to automate the
The bonus eligibility process.
Intervention
• Skeptical at first, Ananya agreed to
pilot the idea, provided it remained
simple, readable, and relevant to
business logic.
Over the next few sessions, Dev
demonstrated how Python could:
Loop through
Store employee Apply eligibility
multiple
data logic
employees

Be expanded using
Display clean Save results to a object-oriented
output file design for
reusability
Steps Taken (Scene-wise Learning)

Scene Business Need Python Concept Used

1 Store name, experience, sales data Variables, Data Types

2 Check who qualifies for bonus Operators, Logical Expressions

3 Make eligibility decisions Conditional Statements (if)

4 Automate for all employees Lists and for loops

5 Reuse logic in future Functions (def, return)

6 Create professional messages String Methods, f-strings

7 Save results for payroll reference File Handling, Exception

8 Build scalable system per employee Classes and Objects


Scene 1: The Chaos Begins –
Variables & Data Types
Story:
Ananya, the HR manager, gets a monthly spreadsheet with names, years of
service, and sales. She needs to manually figure out who gets a bonus.
Concept:
We need to store employee information clearly.
Rules:
•Use = to assign values
•Use meaningful variable names
•Match data type: str, int, float
1. What is a Variable?
A variable is a name you assign to store a piece of data in
memory.
Think of it like a label on a file folder in an office.
You can name the folder “employee_name” and put “Ananya”
inside it.
Scene 2: The Rule of Two –
Operators & Logical Conditions
Story:
The bonus rule is simple: if years > 2 and sales > 50000, the employee
qualifies.
Concept:
Use comparison and logical operators to check the rule.
Rules:
•Use >, <, >=, == for comparisons
•Use and, or to combine conditions
Golden Rules for Beginners
Scene 3: Decision Time –
Conditional Statements
Story:
If the rule is met, Ananya gives a bonus. If not, she doesn’t.
Concept:
Make decisions in code using if-else.
Rules:
•Start with if
•Use else for the opposite
•Indent the code block inside the condition
Indentation in
Python

• In Python, indentation is used to


define blocks of code. It tells
the Python interpreter that a
group of statements belongs to
a specific block.
• All statements with the same
level of indentation are
considered part of the same
block.
• Indentation is achieved using
whitespace (spaces or tabs) at
the beginning of each line.
What it means Python uses indentation (spaces or tabs) to
define which lines of code belong together,
in Python: especially inside if blocks, loops, and functions.

Think of indentation like bullet points under a


heading.
Just like in a document, indentation shows
hierarchy or grouping.
Scene 4: Repeat for Everyone –
Loops & Lists
Story:
Manually doing this for 200 employees is tiring! Let’s automate it.
Concept:
Use lists and for loops to process multiple records.
Rules:
•Store multiple records in a list
•Loop through each employee using for
•Unpack tuple values with name, years, sales = emp
List of Tuples – Business Record Format
• Each employee has multiple values (name, experience, sales). Combine them using a
tuple inside a list:
Real-World Business Uses
Scene 5: Build the Bonus Bot –
Functions
Story:
Dev suggests putting the logic inside a function to reuse it easily.
Concept:
Wrap rules inside a function for better structure.
Rules:
•Use def to define
•Pass input through parameters
•Use return to give back a result
Scene 6: Make It Beautiful –
String Methods & f-Strings
Story:
Ananya wants professional-looking messages: names in caps, values formatted.
Concept:
Use string methods and f-strings to beautify output.
Rules:
•Use .upper() to capitalize
•Use f"{...}" to combine variables in text
•Format currency with :.2f
Scene 7: Saving Results – File
Handling & Exceptions
Story:
Now Ananya wants the results saved to a file for payroll.
Concept:
Write output to a text file and handle errors.
Rules:
•Use with open(..., "w") for writing
•Use try-except for error handling
Scene 8: Smart Employees –
Classes & Objects
Story:
Ananya wants each employee to be more than data. She wants them to “know”
their own bonus.
Concept:
Use a class to bundle data and behavior.
Rules:
•Use class and __init__ to create objects
•Add methods like .is_eligible() and .summary()
•Use self to refer to the object’s data
What Are Classes and Objects?

A class is a blueprint or template for creating things


(objects) that share the same structure and behavior.

An object is an actual thing (created using the class) that


holds data and functions.
Impact

• Bonus decisions were now automated and auditable


HR team understood the logic thanks to readable Python
code
The solution was lightweight, free, and scalable
Ananya felt empowered: “I never imagined I could automate
HR logic myself.”
Discussion Questions
What are the limitations of using Excel for this kind of repetitive task?

How did Python improve both accuracy and efficiency?

Why is it useful to convert business logic into a function?

How does using a class help in organizing employee-level data?

What risks could be handled using try-except blocks?

You might also like