Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class called Person with the following attributes: name - A string representing the person's name age - An int representing the person's age

Create a class called Person with the following attributes:

  • name - A string representing the person's name
  • age - An int representing the person's age in years

As well as appropriate __init__ and __str__ methods, include the following methods:

  • get_name(self) - returns the name of the person
  • get_age(self) - returns the age of the person
  • set_name(self, new_name) - sets the name for the person
  • set_age(self, new_age) - sets the age for the person
  • is_older_than(self, other) - returns True if this person is older than the one passed as the other parameter, False otherwise

class Person: # TODO: Implement this class properly def __init__(self, name, age): pass

def __str__(self): pass

def get_name(self): pass

def get_age(self): pass

TESTS:

Alice and Bob

Expected Output

Bob is older than Alice

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

New Trends In Databases And Information Systems Adbis 2019 Short Papers Workshops Bbigap Qauca Sembdm Simpda M2p Madeisd And Doctoral Consortium Bled Slovenia September 8 11 2019 Proceedings

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Robert Wrembel ,Mirjana Ivanovic ,Johann Gamper ,Mikolaj Morzy ,Theodoros Tzouramanis ,Jerome Darmont

1st Edition

3030302776, 978-3030302771

More Books

Students also viewed these Databases questions

Question

Describe the social tasks and challenges of adolescence.

Answered: 1 week ago