Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

ENCAPSUALTION

class Employee:
    # constructor
    def __init__(self, name, salary, project):
        # data members
        self.name = name
        self.salary = salary
        self.project = project

    # method
    # to display employee's details
    def show(self):
        # accessing public data member
        print("Name: ", self.name, 'Salary:', self.salary)

    # method
    def work(self):
        print(self.name, 'is working on', self.project)

# creating object of a class
emp = Employee('Jessa', 8000, 'NLP')

# calling public method of the class
emp.show()
emp.work()
Comment

PREVIOUS NEXT
Code Example
Python :: opening aws images with pillow 
Python :: python callables 
Python :: pandas reverse explode 
Python :: accessing list elements in python 
Python :: Display tail of the DataFrame 
Python :: import starting with number 
Python :: python any( in list FOR LOOP 
Python :: PySimpleGUI and tkinter with camera on Android 
Python :: move a file in python 
Python :: flask env variable 
Python :: python Detect Cycle in a Directed Graph 
Python :: plot multiple ROC in python 
Python :: How to join or combine multiple csv files with concatenate and export dataframe to csv format 
Python :: pandas get most occurring value for each id 
Python :: python csv file plot column 
Python :: set_debug 
Python :: 3x4 matrix 
Python :: enumerate count 
Python :: list comperhension condition in python 
Python :: how to assign key and value to hash dictionary in python 
Python :: python get all the items list 
Python :: online python pseudo code writer python 
Python :: when i press tab it shows ipynb_checkpoints/ in jupyter notebook 
Python :: how to save all countries from a list in a database python 
Python :: python scrape data from aspx page 
Python :: list to string without loop 
Python :: iterating over the two ranges simultaneously 
Python :: pandas get data from upper row 
Python :: Improve the Request Handle Errors 
Python :: admin email errors 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =