Advertisement
snip3r77

Untitled

Jan 25th, 2019
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. 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.
  2.  
  3. Hint: You call the string method .format() within the print_stats() method to help you return the full set of information.
  4.  
  5. Output :
  6. band: Queen members: 4 albums: 15 sold: 105000000 genre: Rock
  7.  
  8. class Band(object):
  9.     def __init__(self,band,members,albums,sold,genre):
  10.         self.band=band
  11.         self.members= members
  12.         self.albums= albums
  13.         self.sold = sold
  14.         self.genre = genre
  15.    
  16.     def print_stats(self):
  17.         return 'band: {} members: {} albums: {} sold: {} genre: {}'.format(self.band,self.members,self.albums,self.sold,self.genre)
  18.        
  19. queen = Band("Queen", 4, 15, 10500000, "Rock")
  20. print(queen.print_stats())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement