Demonstrate use of Object Oriented Programming (OOP) principles, data structures and file handling operations to carry out the following tasks:
a) Define a class named Person, with child classes named Daughter and Son who also have have derived classes named GrandSon and GrandDaughter respectively. All child classes have derived genetic features and skills from Person. Create 5 methods for getting and setting genetic features, setting and getting skills and demonstrate the concept of polymorphism.
b) Modify the answer in a) and show how the person features are captured in a file called person.txt. Also create another method to read from the file person.csv and store the data in a list called persondata. Clearly show how exceptions are handled in your program
class Person:
def __init__(self, name):
self.name = name
def say_hi(self):
print("Hello,", self.name)
class Son(Person):
pass
class Daughter(Person):
pass
with open("input.txt", 'r') as reader:
print(reader.read())
Comments
Leave a comment