What is encapsulation in python?

Binding the data and data member in single unit is call encapsulation

if we define the data and data member private.you can't access outside class

Private Variables : we can access only with in the class

class A10:
	__fname="Ashu"
	def display(self):
		return self.__fname
a1=A10()
print(a1.display())	
#private variable can't 
#access outside class
print(A10.__fname)
    print(A10.__fname)
AttributeError: type object 'A10' has no attribute '__fname'
class A10:
	__fname="Ashu"
	def display(self):
		return self.__fname
a1=A10()
print(a1.display())
Ashu

Private Method : we can access only with in the class

class A10:
	
	def __display(self):
		return "private method"
	def call(self):
		print(self.__display(),"call by other method inside class")	
a1=A10()
a1.call()
#private method can't 
#access outside class
print(A10.__display())
    print(A10.__display())
AttributeError: type object 'A10' has no attribute '__display'
class A10:
	def __display(self):
		return "private method"
	def call(self):
		print(self.__display(),"call by other method inside class")	
a1=A10()
a1.call()
private method call by other method inside class

Getter and Setter in python

class Employee:
	def setFName(self,fname):
		self.__fname=fname
	def getFName(self):
		return self.__fname
	def setLName(self,lname):
		self.__lname=lname
	def getLName(self):
		return self.__lname
	def setEmail(self,email):
		self.__email=email
	def getEmail(self):
		return self.__email

e1=Employee()
e1.setFName("ashu")
e1.setLName("mishra")
e1.setEmail("ashu@gmail.com")
print(e1.getFName()," ",e1.getLName()," ",e1.getEmail())			
ashu   mishra   ashu@gmail.com

Setter and Getter with using __str__() method

class Employee:
	def setFName(self,fname):
		self.__fname=fname
	def getFName(self):
		return self.__fname
	def setLName(self,lname):
		self.__lname=lname
	def getLName(self):
		return self.__lname
	def setEmail(self,email):
		self.__email=email
	def getEmail(self):
		return self.__email
	def __str__(self):
		return self.__fname+" "+self.__lname+" "+self.__email
e1=Employee()
e1.setFName("ashu")
e1.setLName("mishra")
e1.setEmail("ashu@gmail.com")
print(e1)
e2=Employee()
e2.setFName("arun")
e2.setLName("singh")
e2.setEmail("arun@gmail.com")
print(e2)			
ashu mishra ashu@gmail.com
arun singh arun@gmail.com