Quiz on Methods in Python
Python is a very flexible language with a lot of functions and methods. In this part of our quiz on Python Methods, we will be focussing on the methods specifically. Without wasting any further time let’s move ahead and attempt the quiz. 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 methods can we create? Which of these is a necessity when we use a method? Which of the following is true? Which of the following depicts the use of self parameter in methods? What is the use of the __init__() method in python? Identify the method in the code given below? # Code snippet starts class org: def __init__(self,orgName): self.orgName = orgName def printOrgName(self): print(self.orgName) org1 = org(‘QuizOrbit’) org1.printOrgName() # Code snippet ends What type of method is __init__() in the code given below? # Code snippet starts class org: def __init__(self,orgName): self.orgName = orgName def printOrgName(self): print(self.orgName) org1 = org(‘QuizOrbit’) org1.printOrgName() # Code snippet ends Find the number of objects in the code given below? # Code snippet starts class org: def __init__(self,orgName): self.orgName = orgName def printOrgName(self): print(self.orgName) class employee(org): def __init__(self,empName,empId,empSal): self.empName = empName self.empId = empId self.empSal = empSal def getEmpDetails(self): print(“EmpId: “+self.empId+” EmpName: “+self.empName) org1 = org(‘QuizOrbit’) emp1 = employee(‘Ravi’,’A32′,5000) emp1.getEmpDetails() # Code snippet ends What is the total of class and method extensions used in the code given below? # Code snippet starts class org: def __init__(self,orgName): self.orgName = orgName def printOrgName(self): print(self.orgName) class employee(org): def __init__(self,empName,empId,empSal): self.empName = empName self.empId = empId self.empSal = empSal def getEmpDetails(self): print(“EmpId: “+self.empId+” EmpName: “+self.empName) org1 = org(‘QuizOrbit’) emp1 = employee(‘Ravi’,’A32′,5000) emp1.getEmpDetails() # Code snippet ends Find the output of the code given below? # Code snippet starts class org: def __init__(self,orgName): self.orgName = orgName def printOrgName(self): print(self.orgName) class employee(org): def __init__(self,empName,empId,empSal): self.empName = empName self.empId = empId self.empSal = empSal def getEmpDetails(self): print(“EmpId: “+self.empId+” EmpName: “+self.empName) org1 = org(‘QuizOrbit’) emp1 = employee(‘Ravi’,’A32′,5000) emp1 = employee(‘Chavvi’,’A37′,10000) print(emp1.empId) # Code snippet ends Find the error in the following code? # Code snippet starts class org: def __init__(self,orgName): self.orgName = orgName def printOrgName(self): print(self.orgName) class employee(org): def __init__(self,empName,empId,empSal): self.empName = empName self.empId = empId self.empSal = empSal def getEmpDetails(self): print(“EmpId: “+self.empId+” EmpName: “+self.empName) org1 = org(‘QuizOrbit’) emp1 = employee(‘Ravi’,’A32′,5000) emp1 = employee(‘Chavvi’,’A37′,10000) print(emp1.orgName) # Code snippet ends How many times constructor is being run in the code given below? # Code snippet starts class animal: def __init__(self,name,food): self.name = name self.food = food def getDetails(self): print(self.name,self.food) lion = animal(‘Leo’,’meat’) cow = animal(‘Roger’,’grass’) cow = animal(‘Rogers’,’grass’) # Code snippet ends Find the output of the code given below? # Code snippet starts class animal: def __init__(self,name,food): self.name = name self.food = food def getDetails(self): print(self.name,self.food) lion = animal(‘Leo’,’meat’) cow = animal(‘Roger’,’grass’) cow = animal(‘Rogers’,’grass’) bird = animal(‘tweety’,’worms’) del bird bird.getDetails() # Code snippet ends How many arguments should be passed to the exp object to make code error-free? # Code snippet starts class claculator: def __init__(self,a,b): self.a = a self.b = b def add(a,b): return a+b def subtract(self): return abs(self.a-self.b) exp = claculator() # Code snippet ends Identify the object in the code given below? # Code snippet starts class org: def __init__(self,orgName): self.orgName = orgName def printOrgName(self): print(self.orgName) org1 = org(‘QuizOrbit’) org1.printOrgName() # 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
Methods are the backbone of any python application. We hope with this quiz you might have understood more about methods in Python. Keep attempting more and more quizzes and improving your python skills. Happy Learning!