Question
main.py # TODO: Import Artist from Artist.py and Artwork from Artwork.py if __name__ == __main__: user_artist_name = input() user_birth_year = int(input()) user_death_year = int(input()) user_title
main.py
# TODO: Import Artist from Artist.py and Artwork from Artwork.py
if __name__ == "__main__": user_artist_name = input() user_birth_year = int(input()) user_death_year = int(input()) user_title = input() user_year_created = int(input())
user_artist = Artist(user_artist_name, user_birth_year, user_death_year)
new_artwork = Artwork(user_title, user_year_created, user_artist) new_artwork.print_info()
Artist.py
class Artist: # TODO: Define constructor with parameters to initialize instance attributes # (name, birth_year, death_year)
def print_info(self): if self.birth_year >= 0 and self.death_year >= 0: print(f'Artist: {self.name} ({self.birth_year} to {self.death_year})') elif self.birth_year >= 0: print(f'Artist: {self.name} ({self.birth_year} - present)') else: print(f'Artist: {self.name} (unknown)')
Artwork.py
# TODO: Import Artist from Artist.py
class Artwork: # TODO: Define constructor with parameters to initialize instance attributes # (title, year_created, artist)
def print_info(self): self.artist.print_info() print(f'Title: {self.title}, {self.year_created}')
Define the Artist class in Artist.py with a constructor to initialize an artist's information. The constructor should by default initialize the artist's name to "unknown" and the years of birth and death to - 1. Define the Artwork class in Artwork.py with a constructor to initialize an artwork's information. The constructor should by default initialize the title to "unknown", the year created to -1, and the artist to use the Artist default constructor parameter values. Add an import statement to import the Artist class. Add import statements to main.py to import the Artist and Artwork classes. Ex: If the input is: Pablo Picasso 1881 1973 Three Musicians 1921 the output is: Artist: Pablo Picasso (1881 to 1973) Title: Three Musicians, 1921 Ex: If the input is: BriceMarden19381DistantMuses2000 the output is: Artist:BriceMarden(1938topresent)Title:DistantMuses,2000 Ex: If the input is: Banksy -1 -1 Balloon Girl 2002 the output is: Artist: Banksy (unknown) Title: Balloon Girl, 2002Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started