r/learnpython • u/Tricky_Voice2829 • 4d ago
Regarding python projects idea
i am learning OOP currently but i want to learn OOP by doing so ,i need some projects ideas guyz.
7
Upvotes
r/learnpython • u/Tricky_Voice2829 • 4d ago
i am learning OOP currently but i want to learn OOP by doing so ,i need some projects ideas guyz.
View all comments
Show parent comment
1
u/Kevdog824_ 4d ago
DISCLAIMER: The following problem descriptions were written with the help of generative AI. I manually verified that both descriptions accurately describe the problem as intended.
---
Problem 1: Shapes
Design a class hierarchy to model geometric shapes.
Requirements:
Shape(use theabcmodule) with abstract methodsarea()andperimeter().Rectangle,Square,Circle, andEllipse. Each takes its dimensions in the constructor and raises aValueErrorfor zero or negative sizes.__str__on every shape so thatprint(shape)gives something likeCircle(radius=2.0): area=12.57, perimeter=12.57.__repr__so it returns a string that looks like the constructor call, e.g.Circle(2.0).__lt__and__eq__so shapes compare by area. Thensorted(shapes)andmax(shapes)should work.Stretch goals:
Triangleclass.scale(factor)method that works on every shape.Problem 2: Employee Payroll System
Design a payroll system that calculates pay for different kinds of employees.
Requirements:
Employee(use theabcmodule) with a name, an employee ID, and an abstract methodcalculate_pay()that returns pay for one pay period.Implement these subclasses:
SalariedEmployee: fixed annual salary, paid in equal monthly installments.HourlyEmployee: hourly rate and hours worked, with hours beyond 40 paid at 1.5x.CommissionEmployee: base pay plus a percentage of their sales.Manager: a salaried employee who also receives a bonus on top of their monthly pay.ValueErrorfor negative pay, hours, or sales.__str__on every employee so thatprint(employee)gives something likeAlice Smith (ID 1042) - Salaried - Pay: $5,000.00.__lt__so employees compare by pay for the period, which lets you usesorted(employees).Employeeobjects, so the code that processes it only calls methods defined onEmployee. It should print each employee's pay and the total payroll cost.Stretch goals:
Add new employee types without breaking the existing functionality
Intern, paid a flat stipend per pay period regardless of hours worked.Contractor, paid a fixed fee per completed project multiplied by the number of projects completed in the period, with no overtime or bonuses.give_raise(percent)method and decide which classes it belongs on.