Create a program with two methods, one method for displaying your full name and the
other method displays your address.
Here is the program bearing the two methods:
# A program with two methods
class Person():
"""Representing a person."""
def __init__(self, first_name, last_name, street, city, state, ZIP_code):
"""Initialize the name and address attributes."""
self.first_name = first_name
self.last_name = last_name
self.street = street
self.city = city
self.state = state
self.ZIP_code = ZIP_code
def get_full_name(self):
"""Print a neatly formatted full name."""
full_name = self.first_name + ' ' + self.last_name
return full_name.title()
def get_address(self):
"""Print the person's address."""
address = self.street.title() + ", " + self.city.title() + ", " + \
self.state.upper() + " " + str(self.ZIP_code)
return address
Comments
Leave a comment