In: Computer Science
Every answer shown for this question appears to be giving an error message or locking the database or telling me there is an operational error or undefined parameter of some sort. Here is the question. This is for Python3
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 "None" and the years of birth and death to 0.
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 "None", the year created to 0, 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.
if this is input:
Pablo Picasso
1881
1973
Three Musicians
1921
what is output
As per the problem statement I have solve the problem. Please let
me know if you have any doubts or you want me to modify the answer.
And if you find this answer useful then don't forget to rate my
answer as thumps up. Thank you! :)
Code:
//main.py
# import artist class
from Artist import Artist
# import artwork class
from Artwork import Artwork
# main
if __name__ == "__main__":
# artist name
artist_name = input()
# artist birth year
artist_birth_year = int(input())
# artist death year
artist_death_year = int(input())
# artist creativity title
user_title = input()
# year when artist made creativity
year_created = int(input())
# artist details
artist = Artist(artist_name, artist_birth_year,
artist_death_year)
#artist artwork details
artwork = Artwork(user_title, year_created,
artist)
artwork.print_info()
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//artist.py
# class artist
class Artist:
# artist birth year and death year
def __init__(self, name = 'None', birth_year =
0, death_year = 0):
self.name = name
self.birth_year =
birth_year
self.death_year =
death_year
# artist info
def print_info(self):
if self.death_year ==
-1:
print('Artist: {}, born {}'.format(self.name,
self.birth_year))
else:
print('Artist: {} ({}-{})'.format(self.name, self.birth_year,
self.death_year))
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//Artwork.py
# class artist
class Artist:
# artist birth year and death year
def __init__(self, name = 'None', birth_year =
0, death_year = 0):
self.name = name
self.birth_year =
birth_year
self.death_year =
death_year
# artist info
def print_info(self):
if self.death_year ==
-1:
print('Artist: {}, born {}'.format(self.name,
self.birth_year))
else:
print('Artist: {} ({}-{})'.format(self.name, self.birth_year,
self.death_year))
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Program Output: