My Report

Python Programming Practice 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

1. All subclasses are a subtype in object-oriented programming.

2. Syntax errors are also known as parsing errors.

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

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

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

class Demo:
     def __init__(self):
         self.a = 1
         self.__b = 1
 
     def get(self):
         return self.__b

obj = Demo()
print(obj.get())

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

class objects:
    def __init__(self):
        self.colour = None
        self._shape = "Circle" 

    def display(self, s):
        self._shape = s
obj=objects()
print(obj._objects_shape)

6. Which of the following statements is true?

7. Identify the type of error in the following Python codes?

Print(“Good Morning”)
print(“Good night)

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

#generator
def f(x):
    yield x+1
g=f(8)
print(next(g))

9. Which of these is not a fundamental features of OOP?

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

def f(x):
    yield x+1
    print("test")
    yield x+2
g=f(10)
print(next(g))
print(next(g))

 

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.