← 2023 questions

2023 / SPOTIFY / QUESTION 7

Song queue

Try the question in your own editor, then check your output below.

THE QUESTION

Vignesh’s favourite Spotify artists are Sufjan Stevens and Bruno Major. He has decided that he wants the songs ‘Murder And Crime’, ‘To Let A Good Thing Die’ ‘Reach Out’, ‘Home’ and ‘Mystery of Love’ to be queued thrice each. Print his Spotify queue list in the following format ‘number. song name’, with each subsequent song starting on a new line. Use a loop function to generate the numbers of the song queue.

Use the following code as a starting point:

Song1 = 'Murder And Crime – Sufjan Stevens'
Song2 = 'To Let A Good Thing Die – Bruno Major'
Song3 = 'Reach Out – Sufjan Stevens'
Song4 = 'Home – Bruno Major'
Song5 = 'Mystery of Love – Sufjan Stevens'

The output should look like this:

1. Murder And Crime – Sufjan Stevens
2. Murder And Crime – Sufjan Stevens
3. Murder And Crime – Sufjan Stevens
4. To Let A Good Thing Die – Bruno Major
5. To Let A Good Thing Die – Bruno Major
6. To Let A Good Thing Die – Bruno Major
7. Reach Out – Sufjan Stevens
8. Reach Out – Sufjan Stevens
9. Reach Out – Sufjan Stevens
10. Home – Bruno Major
11. Home – Bruno Major
12. Home – Bruno Major
13. Mystery of Love – Sufjan Stevens
14. Mystery of Love – Sufjan Stevens
15. Mystery of Love – Sufjan Stevens

Question by Tze Wey. Source: Girls In Code SEA — Behind the Screens, 2023, slide 22.

CHECK YOUR ANSWER

Try your answer.

Run your program in your own editor, then paste its output below. This checks the stated output; it does not assess your full program. Practice attempts do not affect competition scores.

Paste all 15 numbered lines, including song and artist.

Reveal worked answer

Numbered queue

1. Murder And Crime – Sufjan Stevens
2. Murder And Crime – Sufjan Stevens
3. Murder And Crime – Sufjan Stevens
4. To Let A Good Thing Die – Bruno Major
5. To Let A Good Thing Die – Bruno Major
6. To Let A Good Thing Die – Bruno Major
7. Reach Out – Sufjan Stevens
8. Reach Out – Sufjan Stevens
9. Reach Out – Sufjan Stevens
10. Home – Bruno Major
11. Home – Bruno Major
12. Home – Bruno Major
13. Mystery of Love – Sufjan Stevens
14. Mystery of Love – Sufjan Stevens
15. Mystery of Love – Sufjan Stevens

Repeat each song three times before moving to the next song, numbering continuously from 1 to 15.