Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Task: For this challenge, write the code needed to define a class for a band, initiate it for the band Queen, and return the printed stats as shown below.
- Hint: You call the string method .format() within the print_stats() method to help you return the full set of information.
- Output :
- band: Queen members: 4 albums: 15 sold: 105000000 genre: Rock
- class Band(object):
- def __init__(self,band,members,albums,sold,genre):
- self.band=band
- self.members= members
- self.albums= albums
- self.sold = sold
- self.genre = genre
- def print_stats(self):
- return 'band: {} members: {} albums: {} sold: {} genre: {}'.format(self.band,self.members,self.albums,self.sold,self.genre)
- queen = Band("Queen", 4, 15, 10500000, "Rock")
- print(queen.print_stats())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement