How do we implement abstract method in python? Give an example for the same.
Abstract method: An unimplemented method is called an abstract method. When an abstract method is declared in a base class, the derived class has to either define the method or raise 'NotImplementedError'.
class Shape(object):
def findArea(self):
pass
class Square(Shape):
def __init__(self,side):
self.side = side
def findArea(self):
return self.side * self.side
What will be the status of the following list after the First, Second and Third pass of the insertion sort method used for arranging the following elements in descending order?
22, 24, 64,
34, 80, 43
Note: Show the status of all the elements after each pass very clearly underlining the changes.
For a given list of values in descending order, write a method in python to search for a value with the help of Binary Search method. The method should return the position of the value and should return -1 if the value not present in the list.
Write Insert(Place) and Delete(Place) methods in python to add Place and RemovePlace considering them to act as Insert and Delete operations of the data structure Queue.
Write a method in python to find and display the prime numbers between 2 to N.Pass N as the argument to the method.
Evaluate the following postfix notation of expression. Show status of the stack after every operation.
22,11,/,14,10,,+,5,2
Write a statement in Python to perform the following operations:
Write a method in python to write multiple line of text contents into a text file myfile.txt line.
Consider the following definition of class Staff, write a method in python to search and display the content in a pickled file staff.dat, where Staff code is matching with ‘S0105’.
class Staff:
def __init__(self,S,SNM):
self.Staffcode=S
self.Name=SNM
def Show(self):
print(self.Staffcode,' ',
self.Name)
Observe the following STUDENTS and EVENTS tables carefully and write the name of the RDBMS operation which will be used to produce the output as shown in LIST? Also, find the Degree and Cardinality of the LIST.
STUDENTS
No | Name |
1 | Tara Mani |
2 | Jaya Sarkar |
3 | Tarini Trikha |
EVENTS
EVENTCODE | EVENTNAME |
1001 | Programming |
1002 | IT Quiz |
LIST
No | Name | EVENTCODE | EVENTNAME |
1 | Tara Mani | 1001 | Programming |
1 | Tara Mani | 1002 | IT Quiz |
2 | Jaya Sarkar | 1001 | Programming |
2 | Jaya Sarkar | 1002 | IT Quiz |
3 | Tarini Trikha | 1001 | Programming |
3 | Tarini Trikha | 1002 | IT Quiz |