Create a class Employee with data members: name, department and salary. Create suitable methods for reading and printing employee information. ((MSBTE Pratical Question))
Code:
class Employee:
name = ""
department = ""
salary = 0
def getdata(self):
self.name =
input("Enter your name: ")
self.department =
input("Enter your department: ")
self.salary =
input("Enter your salary: ")
def putdata(self):
print("Employee
name:",self.name)
print("Department
name:",self.department)
print("Salary:",self.salary)
e1 = Employee()
e1.getdata()
e1.putdata()
Output:
Comments
Post a Comment