Skip to content

csit08/Hierarchical-inheritance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

Hierarchical-inheritance

from datetime import date class person: # Initalize the Person object with a name, country, and of birth def init(self,name,country, date_of_birth): self.name = name self.country = country self.date_of_birth = date_of_birth #Calculate the of the person based on their date of birth def calculate_age(self): today = date.today() age = today.year - self.date_of_birth.year if today < date(today.year, self.date_of_birth.month, self.date_of_birth.day): age-=1 return age

create three person objects with different attritubes

person1 = person("Ramu", "ongole", date(2003, 7, 12))

#Access and print the attributes and calculated age for each person print("calculated age for each person") print("********************************") print("person 1:") print("Name:", person1.name) print("Country:", person1.country) print("Date of Birth:",person1.date_of_birth) print("Age:", person1.calculate_age())

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published