Create a class “Teacher” with attributes like Teacher_Id, Teacher_Name, Designation, Emailid, Birthdate, City. a.GetData() to take Teacher's information. b.SetData() to display Teacher's information. Inherit class “Account” with attributes like acc_id, acc_type, amount and methods to generate account report of particular teacher in proper format. Implement regular expression to validate emailid and birthdate. - Pratik Ghelani

Pratik Ghelani

Breaking

Sunday, May 10, 2020

Create a class “Teacher” with attributes like Teacher_Id, Teacher_Name, Designation, Emailid, Birthdate, City. a.GetData() to take Teacher's information. b.SetData() to display Teacher's information. Inherit class “Account” with attributes like acc_id, acc_type, amount and methods to generate account report of particular teacher in proper format. Implement regular expression to validate emailid and birthdate.

Input:-

import re
class Teacher(object):
    teacher_id=0
    teacher_name=""
    designation =""
    Email_id=""
    DOB =""
    City =""
    emailmatch = "^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$"
    dateofbirthmatch = "^[0-3]?[0-9]/[0-3]?[0-9]/(?:[0-9]{2})?[0-9]{2}$"
    def set(self,teacher_id,teacher_name,designation,Email_id,DOB,City):
        self.teacher_id=teacher_id
        self.teacher_name=teacher_name
        self.designation=designation
        self.Email_id=Email_id
        self.DOB=DOB
        self.City=City
    def get(self):
        print()
        print("Teacher details:-")
        print("Teacher id:-",self.teacher_id)
        print("Teacher Name:-",self.teacher_name)
        print("designation:-",self.designation)
        if(re.search(self.emailmatch,self.Email_id)):
            print(self.Email_id,"is Valid")
        else:
            print(self.Email_id,"is not Valid")
        if(re.search(self.dateofbirthmatch,self.DOB)):
            print(self.DOB,"is Valid")
        else:
            print(self.DOB,"is not Valid")
        print("City:-",self.City)

class Account(Teacher):
    acc_id=0
    acc_type=""
    amount=0

    def set(self,acc_id,acc_type,amount):
        self.acc_id=acc_id
        self.acc_type=acc_type
        self.amount=amount
    def get(self):
        print()
        print("Account details:-")
        print("Account id:-",self.acc_id)
        print("Account type:-",self.acc_type)
        print("Amount:-",self.amount)

m = Teacher()
m.set(1,"Parth Shah","Assistant Professor","parthshah01@gmail.com","27/06/1993","Surat")
m.get()
m.set(1,"Parth Shah","Assistant Professor","parthshahgmail.com","27/1993","Surat")
m.get()

h = Account()
h.set(2,"Saving Account",10000000)

h.get()

Output:-

No comments:

Post a Comment