Final answer:
Building a program to manage a song playlist using a queue can be achieved with a Python list. You can add songs to the playlist, show the current song, print all songs, remove the front song, and get the size of the playlist queue.
Step-by-step explanation:
Python Program for Song Playlist Queue
To manage a playlist using a queue in Python, you can utilize a list to implement the queue functionality.
Initial Setup
Create an empty queue and define the function to add songs:
playlist_queue = []
def add_song_to_queue(
song):
playlist_queue.append(song)
Show Front Song
To show the front song without removing it from the queue:
current_song = playlist_queue[0]
print("Current song:", current_song)
Print All Songs
To print all songs in the playlist queue:
for song in playlist_queue:
print(song)
Remove Front Song
To remove the song at the front of the queue:
removed_song = playlist_queue.pop(0)
Queue Size
Finally, to print the size of the queue:
queue_size = len(playlist_queue)
print("Size of playlist queue:", queue_size)