× Python Introduction What is Python Python Features Python History Python Applications Python Install Python Path Python Example Execute Python Keywords Constant Variable Statements & Comments Python I/O and Import Operators UnaryBinaryTernary Unary Operators Unary Minus Binary Operators Arithmetic Operators Assignment Operators Relational Operators Logicaloperators Bitwise Operator Ternary Operators Control Statements in Python conditonal Statements IF if else Else If Nested if Switch For loop Nested For Loop While Loop Nested while Loop Unconditonal Statemets Continue Break Pass FUNCTIONS Python Function Function Argument Python Recursion Anonymous Function Python Modules NATIVE DATATYPES Python List Python Numbers Python Tuple Python String Python Set Python Dictionary OOPS PRINCIPALS Encapsulation Class Variable Method Object Or Instance CreationMethod Calling OOPS Syntax And Explanation DATA ABSTRACTION Constructor Inheritance 1.Single or simple Inheritance 2.Multilevel Inheritance 3.Hierarchical Inheritance 4.Multiple Inheritance 5.Hybrid Inheritance Operator Overloading File Operation Python Directory Python Exception Python - Multithreading Python - Database Access Python - CGI Python - Reg Exp Python - Date Python - XML Processing Python - GUI
  • iconPython Online Training In Andhra Pradesh and Telangana
  • icon9010519704

Opening Hours :7AM to 9PM

Data Abstraction in Python


Data Abstraction:
Hiding of implementation or hiding of attributes from the unauthorized behavior from the class is known as Data Abstraction.
In Python language Data Abstraction can be achieved using 'class' keyword.
as per as Python language concent hiding of variables from the the unauthorized method of class is known as Data Abstraction.The main aim advantage with this security can be provide for the data.
Note: Once encapsulation can be apply the 'Data Abstraction' automatically applied.

Constructors In Python


Constructor
Constructor is a non-static method of a class.Which is used to initilize the values.
Syntax:
def __init__(self,list of parameter/no parameters):
    ....
    ....
In the above syntax init is a Constructor .
In Python language these constructers are classisfied into following types
1.Noparametarized Constructor
2.Parametarized Constructor
1.NoParametarized Constructor:
If any Constructor signature does not contain parameters is known as NoParametarized Constructor
Syntax:
def __init__(self):
    ....
    ....

2.Parametarized Constructor:

If any Constructor signature contains List of parameters is known as Parametarized Constructor
Syntax:
def __init__(self,variable1,variable2,...):
    ....
    ....

Based on the Constructors these methods are classified into following types
1.No Parametarized Constructor with No return type with no Parametarized Method
2.No Parametarized Constructor with No return type with Parametarized Method
3.No Parametarized Constructor with return type with no Parametarized Method
4.No Parametarized Constructor with return type with Parametarized Method
5.Parametarized Constructor with No return type with no Parametarized Method
6.Parametarized Constructor with No return type with Parametarized Method
7.Parametarized Constructor with return type with no Parametarized Method
8.Parametarized Constructor with return type with Parametarized Method

1. No Parametarized Constructor with No return type with no Parametarized Method
2. No Parametarized Constructor with No return type with Parametarized Method
3. No Parametarized Constructor with return type with no Parametarized Method
4. No Parametarized Constructor with return type with Parametarized Method
5. Parametarized Constructor with No return type with no Parametarized Method
6. Parametarized Constructor with No return type with Parametarized Method
7. Parametarized Constructor with return type with no Parametarized Method
8. Parametarized Constructor with return type with Parametarized Method

1. No Parametarized Constructor with No return type with no Parametarized Method
class Factorial:
    def __init__(self):
        self.n=int(input("Enter n value"))


    def fact(self):
       x=1
       f=1
       while(x<=self.n):
           f=f*x;
           x=x+1
       print(f)


if __name__=="__main__":
    ff=Factorial()
    ff.fact()
 

Output:
Y is Max Number
2. No Parametarized Constructor with No return type with Parametarized Method
class Factorial:
    def __init__(self):
        self.n=int(input("Enter n value"))


    def fact(self,x,f):
       
       while(x<=self.n):
           f=f*x;
           x=x+1
       print(f)


if __name__=="__main__":
    ff=Factorial()
    ff.fact(1,1)
 

Output:
Y is Max Number
3. No Parametarized Constructor with return type with no Parametarized Method
class Factorial:
    def __init__(self):
        self.n=int(input("Enter n value"))


    def fact(self):
       x=1
       f=1
       while(x<=self.n):
           f=f*x;
           x=x+1
       return(f)


if __name__=="__main__":
    ff=Factorial()
    s=ff.fact()
    print(s)


Output:
Y is Max Number
4. No Parametarized Constructor with return type with Parametarized Method
class Factorial:
    def __init__(self):
        self.n=int(input("Enter n value"))


    def fact(self,x,f):
      
       while(x<=self.n):
           f=f*x;
           x=x+1
       return(f)


if __name__=="__main__":
    ff=Factorial()
    s=ff.fact(1,1)
    print(s)    

Output:
Y is Max Number
5. Parametarized Constructor with No return type with no Parametarized Method
class Factorial:
    def __init__(self,m):
        self.n=m


    def fact(self):
       x=1
       f=1
       while(x<=self.n):
           f=f*x;
           x=x+1
       print(f)


if __name__=="__main__":
    m=int(input("Enter m value"))
    ff=Factorial(m)
    ff.fact()    

Output:
Y is Max Number
6. Parametarized Constructor with No return type with Parametarized Method

class Factorial:
    def __init__(self,m):
        self.n=m


    def fact(self,x,f):
       
       while(x<=self.n):
           f=f*x;
           x=x+1
       print(f)


if __name__=="__main__":
    m=int(input("Enter m value"))
    ff=Factorial(m)
    ff.fact(1,1)

 

Output:
Y is Max Number
7. Parametarized Constructor with return type with no Parametarized Method

class Factorial:
    def __init__(self,m):
        self.n=m


    def fact(self):
       x=1
       f=1
       while(x<=self.n):
           f=f*x;
           x=x+1
       return(f)


if __name__=="__main__":
    m=int(input("Enter m value"))
    ff=Factorial(m)
    s=ff.fact()
    print(s)

Output:
Y is Max Number
8. Parametarized Constructor with return type with Parametarized Method
    
    
class Factorial:
    def __init__(self,m):
        self.n=m


    def fact(self,x,f):
       
       while(x<=self.n):
           f=f*x;
           x=x+1
       return(f)


if __name__=="__main__":
    m=int(input("Enter m value"))
    ff=Factorial(m)
    s=ff.fact(1,1)
    print(s)    

Output:
Y is Max Number