Python Practice Abstract Exception

In this class, We discuss Python Practice Abstract Exception.

For Complete YouTube Video: Click Here

These examples will help a lot to the reader to understand the concepts of python.

The reader can easily crack the campus placement exams by taking the placement training course.

Try to solve the questions, then check for a solution.

Q1)

james: a child class of an abstract class can be instantiated only if 
       child overrides all the abstract methods of parent class
pavan: an abstract method should have a definition
jack: an abstract method can be overridden in child class(es)
lina: if a parent class has two abstract methods for the child class to be concrete
      should override atleast one of the abstract method
        
        
Which statements are incorrect?

In the above example. The statement given by lina is incorrect.

All the abstract methods should be defined To make a class concrete.

The statement given by pavan is also incorrect.

Abstract methods do not have a definition.

pavan, line statements are incorrect.

Q2)

What is the output displayed by the below code?

def function(samplelist):
    try:
        data=samplelist[2]
        print(data)
    except NameError:
        print("name error")
    finally:
        print("finally finished function")
val=10
try:
    function([1,8,7])
    val=val1//0
except ZeroDivisionError:
    print("divide by zero error")
except:
    print("error outside function")
finally:
    print("finally completed program")

In the above program, the try block has two exceptions.

The variable var1 is not defined in the program.

The exception divide by zero is also there in the try block.

Point to understand: the expression evaluation first identifies name errors.

Given below is the output displayed by the program.

7
finally finished function
error outside function
finally completed program