0% found this document useful (0 votes)
110 views1 page

Asset Distribution in Family Classes

This Python code defines a parent class that tracks total asset worth. It then creates child classes called son and daughter that inherit from the parent class. The son and daughter classes each calculate a share of the total assets based on a percentage passed into their constructors.

Uploaded by

sach
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
110 views1 page

Asset Distribution in Family Classes

This Python code defines a parent class that tracks total asset worth. It then creates child classes called son and daughter that inherit from the parent class. The son and daughter classes each calculate a share of the total assets based on a percentage passed into their constructors.

Uploaded by

sach
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#!

/bin/python3

import math
import os
import random
import re
import sys

class parent:
def __init__(self,total_asset):
self.total_asset = total_asset

def display(self):
print("Total Asset Worth is "+str(self.total_asset)+" Million.")
print("Share of Parents is "+str(round(self.total_asset/2,2))+" Million.")

# It is expected to create two child classes 'son' & 'daughter' for the above class
'parent'
class son(parent):
def __init__(self,total_asset,ps):
parent.__init__(self,total_asset)
self.ps=ps

def son_display(self):
x=(self.total_asset*self.ps)/100
print("Share of Son is "+str(round(x,2))+" Million.")

class daughter(parent):
def __init__(self,total_asset,ps):
parent.__init__(self,total_asset)
self.ps=ps
def daughter_display(self):
x=(self.total_asset*self.ps)/100
print("Share of Daughter is "+str(round(x,2))+" Million.")

if __name__ == '__main__':

You might also like