A program is written for a music playlist creator. It displays the names of available songs, stored in an array. The user enters a number. That number of songs is selected randomly from the array and displayed.
impor random
songList = ["Starlight", "Yesterday", Blackbird,
"Respect", "Heroes"]
print("Available songs:")
for song in songList
print("- " + song)
numSongs = int(input("How many songs would you like to play? "))
print("
Your random playlist:")
for count in range(numSongs - 1):
index = random.
name = songList[index + 1]
print(naime)
Amend the code to:
impor random)for song in songList)index = random.)songList = ...)name = songList[index + 1])print(naime))for count in range(numSongs - 1):)Do not change the basic functionality of the correct parts of the code. Do not add any additional features.
51 exam-style questions on Edexcel GCSE Computer Science Develop code, covering Decomposition and abstraction to solve problems, Read, write, analyse and refine programs, Converting algorithms into programs, Techniques for readable, maintainable code, Identifying and correcting program errors, and Evaluating program fitness and efficiency. Each one has a worked solution and a mark scheme showing where the marks go.