My Report

Python Programming Mock Test 10


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement
 10%

Question 1 of 10

1. What type of inheritance is illustrated in the following Python code?

class A():
    pass
class B(A):
    pass
class C(B):
    pass

Question 1 of 10

Question 2 of 10

2. Is the following Python code valid?

try:
    # Do something
except:
    # Do something
else:
    # Do something

Question 2 of 10

Question 3 of 10

3. The purpose of name mangling is to avoid unintentional access of private class members.

Question 3 of 10

Question 4 of 10

4. What will be the output of the following Python code?

class test:
     def __init__(self,a="Hello World"):
         self.a=a
 
     def display(self):
         print(self.a)
obj=test()
obj.display()

Question 4 of 10

Question 5 of 10

5. What type of inheritance is illustrated in the following Python code?

class A():
    pass
class B():
    pass
class C(A,B):
    pass

Question 5 of 10

Question 6 of 10

6. How many except statements can a try-except block have?

Question 6 of 10

Question 7 of 10

7. What will be the output of the following Python code?

class A:
    def __init__(self):
        self.multiply(15)
        print(self.i)

    def multiply(self, i):
        self.i = 4 * i;
class B(A):
    def __init__(self):
        super().__init__()
        
    def multiply(self, i):
        self.i = 2 * i;
obj = B()

Question 7 of 10

Question 8 of 10

8. What will be the output of the following Python code?

class A:
    def __init__(self):
        self._x = 5       
class B(A):
    def display(self):
        print(self._x)
def main():
    obj = B()
    obj.display()
main()

Question 8 of 10

Question 9 of 10

9. Which function overloads the // operator?

Question 9 of 10

Question 10 of 10

10. Which of the following statements is wrong about inheritance?

Question 10 of 10


 

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.