Class and objects - 3
Python
class Person:
def __init__ (self, name, age, city, country):
self.name = name
self.age = age
self.city = city
self.country = country
self.skills = []
def person_info(self):
return f'{self.name} is {self.age} years old. He lives in {self.city}.'
def add_skills(self, skill):
self.skills.append(skill)
p = Person(name = 'Kiran', age = 23, city = 'california', country = "USA")
p.add_skills("python")
p.add_skills("oracle")
p.add_skills("C")
print(p.person_info())
print(p.skills)
Output
Embed on website
To embed this program on your website, copy the following code and paste it into your website's HTML:
Comments
This comment belongs to a banned user and is only visible to admins.
This comment belongs to a deleted user and is only visible to admins.