Quiz on Constructors in Python
Constructors are used in almost all programming languages and also in python. With this quiz, we aim to provide you with a deeper insight if the concepts of python constructors. Let us now move ahead with our quiz on Python Constructors. All the best!
0 of 15 Questions completed Questions: You have already completed the quiz before. Hence you can not start it again. Quiz is loading… You must sign in or sign up to start the quiz. You must first complete the following: 0 of 15 Questions answered correctly Your time: Time has elapsed You have reached 0 of 0 point(s), (0) Earned Point(s): 0 of 0, (0) How many constructors are available in python? Which of the following is the default constructor in python? How many times a constructor runs in each instantiation? How many constructors can be defined in a class? Which of the following is a built-in attribute in a python class? Find the output of the code given below? # Code snippet starts class claculator: def __init__(self,a,b): self.a = a self.b = b def __init__(self,a=10,b=20): self.a = a self.b = b def display(self): print(self.a,self.b) exp = claculator(100,23) exp.display() # Code snippet ends Which type of constructor is being used in the code given below? # Code snippet starts class claculator: def __init__(self,a,b): self.a = a self.b = b def __init__(self,a=10,b=20): self.a = a self.b = b def display(self): print(self.a,self.b) exp = claculator(100,23) exp.display() # Code snippet ends Which type of constructor is being used in the code given below? # Code snippet starts class Quiz: def getName(self): print(“Enter your name: “) name = input() player = Quiz() player.getName() # Code snippet ends What is the function of the constructor in the code given below? # Code snippet starts class Quiz: def getName(self): print(“Enter your name: “) name = input() player = Quiz() player.getName() # Code snippet ends Find the output of the code given below? # Code snippet starts class org: def __init__(self,name=’QuizOrbit’,loc=’Pune’): self.name = name self.loc = loc def getDetails(self): return self orgDetail = org() print(getattr(orgDetail,’name’)) # Code snippet ends Find the output of the code given below? # Code snippet starts class org: def __init__(self,name=’QuizOrbit’,loc=’Pune’): self.name = name self.loc = loc def getDetails(self): return self orgDetail = org() setattr(orgDetail,’loc’,’Indore’) print(orgDetail.loc) # Code snippet ends Find the output of the code given below? # Code snippet starts class display: def __init__(self): print(“constructor 1”) def __init__(self): print(“no constructor”) led = display() del led # Code snippet ends Find the output of the code given below? # Code snippet starts class display: def __init__(self): print(“constructor 1”) def __init__(self): print(“no constructor”) led = display() # Code snippet ends Find the output of the code given below? # Code snippet starts class claculator: def __init__(self,a,b): self.a = a self.b = b def __init__(self,a=10,b=20): self.a = a self.b = b def display(self): print(self.a,self.b) exp = claculator() print(exp.__doc__) # Code snippet ends Find the output of the code given below? # Code snippet starts class claculator: def __init__(self,a,b): self.a = a self.b = b def __init__(self,a=10,b=20): self.a = a self.b = b def display(self): print(self.a,self.b) exp = claculator(100,23) print(list(exp.__dict__.keys())[1]) # Code snippet ends Quiz Summary
Information
Results
Results
0 Essay(s) Pending (Possible Point(s): 0) Categories
1. Question
2. Question
3. Question
4. Question
5. Question
6. Question
7. Question
8. Question
9. Question
10. Question
11. Question
12. Question
13. Question
14. Question
15. Question
Summary
We hope with the quiz on Python COnstructors, your concepts of constructor would have become crystal clear now. Constructors are integral to any object and thus move forward only after you become comfortable with them. Happy Learning!
huqghfduewhfi
\
quiz is nice