Question: PYTHON PROGRAMMING NEED HELP ASAP You will write an application to manage music collections -- a music collection is a list of albums. The named

PYTHON PROGRAMMING NEED HELP ASAP

You will write an application to manage music collections -- a music collection is a list of albums.

The named tuples used for Albums and Songs are defined below, and an example of a music collection is given. (DO NOT HARDCODE THE VALUES FOR MUSIC!)

Album = namedtuple('Album', 'id artist title year songs') Song = namedtuple('Song', 'track title length play_count') MUSIC = [ Album("1", "Peter Gabriel", "Up", 2002, [Song(1, "Darkness", 411, 5), Song(2, "Growing Up", 453, 5)]), Album("2", "Simple Minds", "Once Upon a Time", 1985, [Song(1, "Once Upon a Time", 345, 9), Song(2, "All the Things She Said", 256, 10)]), Album("TRS", "The Rolling Stones", "Let It Bleed", 1969, [Song(1, "Gimme Shelter", 272, 3), Song(2, "Love In Vain", 259, 2), Song(3, "You Can't Always Get What You Want", 448, 10)]) ]

To achieve this, you need to:

  1. Write a function called get_song_input that has no parameters. This function should prompt the user for the required information to create a new song, create the song and return it. You should require the information as follows:

Enter the song's track:

Enter the song's title:

Enter the song's length:

Enter the song's play_count:

  1. Write a function called get_album_input that has no parameters. This function should prompt the user for the required information to create a new album, create the album and return it. You should require the information as follows:

Enter the album's id:

Enter the album's artist:

Enter the album's title:

Enter the album's year:

Enter the number of songs in this album:

Enter the song's track:

Enter the song's title:

Enter the song's length:

Enter the song's play_count:

Note that the last four lines should be repeated once for each song in the album.

  1. Write a function called add_album that takes a music collection (a list of albums) as a parameter. The function should create a new album, add it to the end of the list, and then return the updated collection.

  2. Write a function called remove_album that takes a music collection (a list of albums) and an ID as parameters. The function should remove the album that has a matching ID from the list, and then return the updated collection. If there is no album with a matching ID, simply print 'Album not found.' and return the collection.

  3. Write a function called favorite_song that takes a music collection and an album ID as parameters. The function returns the song that is the "favorite" from the album that matched the ID. We'll define the favorite song as the one that has the highest playing time. (The playing time of a song is computed using its play_count and length.) If there is no album with a matching ID, return 'Album not found.'.

  4. Write a function called unplayed_songs that takes a music collection and an album ID as parameters. It should return a list of the songs that have not been played from the album that matched the ID. If there is no album with a matching ID, simply print and return'Album not found.'.

  5. Write a function called favorite_album that takes a music collection and returns the album that is the "favorite." We'll define the favorite album as the one that has the highest playing time. (An album's playing time is the sum of all its songs' playing time.)

  6. Write a function called unplayed_albums that takes a music collection and returns a list of the albums that have not been played.

  7. Write a function called print_menu that has no parameters. This function should display the menu (as shown below), and prompt the user for a choice. It should repeat the message 'Choose an option' while the user does not input a valid choice. The function should return the valid choice the user entered. Note that you only print the entire menu once per valid choice. That is, if the user enters an invalid choice, you should not repeat the entire menu, only the 'Choose an option' message.

 

MUSIC COLLECTION MANAGER

add - Add a new album

del - Remove an album

fav_a - Print favorite album

fav_s - Print favorite song

not_a - Print not played albums

not_s - Print not played songs

exit - Exit the application

Choose an option:

  1. Finally, inside the main block of your code (if __name__ == '__main__'), print the menu and perform the action the user requested until they request to exit the application.

HINT: you can call get_song_input the desired amount of times to help create the list of songs for an album.

HINT: you can create extra functions to help you. For instance, a function that takes a song as a parameter and calculates its playing time could be helpful.

 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!