Test your skills through the online practice test: Python Quiz Online Practice Test

Related differences

Python vs JavaPython 2 vs Python 3

Ques 81. What is polymorphism in Python?

By using polymorphism in Python we will understand how to perform a single task in different ways. For example, designing a shape is the task and various possible ways in shapes are a triangle, rectangle, circle, and so on.

Is it helpful? Add Comment View Comments
 

Ques 82. Does Python make use of access specifiers?

Python does not make use of access specifiers and also it does not provide a way to access an instance variable. Python introduced a concept of prefixing the name of the method, function, or variable by using a double or single underscore to act like the behavior of private and protected access specifiers.

Is it helpful? Add Comment View Comments
 

Ques 83. How can we create an empty class in Python?

Empty class in Python is defined as a class that does not contain any code defined within the block. It can be created using pass keywords and object to this class can be created outside the class itself.

Is it helpful? Add Comment View Comments
 

Ques 84. Define Constructor in Python.

Constructor is a special type of method with a block of code to initialize the state of instance members of the class. A constructor is called only when the instance of the object is created. It is also used to verify that they are sufficient resources for objects to perform a specific task.

There are two types of constructors in Python, and they are:

  • Parameterized constructor
  • Non-parameterized constructor

Is it helpful? Add Comment View Comments
 

Ques 85. How can we create a constructor in Python programming?

The _init_ method in Python stimulates the constructor of the class. 

Example:

class Person:
  def __init__(self, name, age):
    self.name = name
    self.age = age

p1 = Person("John", 36)

print(p1.name)
print(p1.age)

Output:

John

16

Is it helpful? Add Comment View Comments
 

Most helpful rated by users: