DEV Community 👩‍💻👨‍💻

Shivani tiwari
Shivani tiwari

Posted on

Write a program by creating an 'Employee' class having the following methods and print the final salary.

this is also a question part

1 - 'getInfo()' which takes the salary, number of hours of work per day of employee as parameter

2 - 'AddSal()' which adds 10 to salary of the employee if it is less than 500.

3 - 'AddWork()' which adds 5 to salary of employee if the number of hours of work per day is more than 6 hours.

Hello Everyone 👋

You must be seeing the above question. So here we discuss the problem

There is some few step which we hove do it-

  1. First we will create a Employee class

  2. Create a 3 methods which is mention the about question

. First method getInfo()
. Second method AddSal()
. third method AddWork()

  1. here we create one more method that is final salary() which give use the employee salary

Here is the Ans of this Problem

class Employee:

    def __init__(self,name):

    def getInfo(self,salary,hours):

    def AddSal(self):
        if self.salary<500:
            return self.salary
    def AddWork(self):
        if self.hours>6:
            return self.salary

    def print_final_salary(self):


name=str(input("enter name:"))
salary=int(input("Enter Salary:"))
hours=float(input("enter hours:"))

Enter fullscreen mode Exit fullscreen mode

I hope you like will help you for your DSA interview preparation

Thank You
Shivani Tiwari

Top comments (0)

What image format should you use in your next project? 🤔