Create a class “Person” with attributes like id, name, city, and designation. a. getData() to take employee information. b. setData() to display employee information. Inherit class “Account” with attributes like acc_id, acc_type, amount and methods to generate account report of user in proper format. ( Python ) - Pratik Ghelani

Pratik Ghelani

Breaking

Sunday, May 10, 2020

Create a class “Person” with attributes like id, name, city, and designation. a. getData() to take employee information. b. setData() to display employee information. Inherit class “Account” with attributes like acc_id, acc_type, amount and methods to generate account report of user in proper format. ( Python )

Input:-


class Person(object):
    id=0
    name=""
    age=""
    designation=""
    city="
 def set(self,id,name,age,designation,city):
        self.id=id
        self.name=name
        self.age=age
        self.designation=designation
        self.city=city
    def get(self):
        print()
        print("Person details:-")
        print("Id:-",self.id)
        print("Name:",self.name)
        print("Age:-",self.age)
        print("Designation:-",self.designation)
        print("City:-",self.city)

class Account(Person):
    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)

i = Person()
i.set(91,"Parth Shah",27,"Developer","Naroli")
i.get()

z=Account()
z.set(3704,"Saving",10000)
z.get()



Output:-

No comments:

Post a Comment