WorksheetsGUI MP3 Player (Grade 9)
Total questions: 10
Worksheet time: 5mins
Which library is used in the code to create the graphical user interface (GUI)?
pygame
tkinter
random
os
What is the purpose of pygame.mixer.init() in the code?
To create a window for the MP3 player
To load the MP3 file into memory
To initialize the pygame mixer for playing audio
To change the background color
What does the function play() do in this code?
It opens a new Tkinter window
It closes the program
It stops the music playback
It loads and plays the MP3 file
What does the play_button do in the program?
Starts playing the music
Closes the MP3 player
Changes the title of the window
Adjusts the volume
What does root.mainloop() do in this program?
It runs the Tkinter event loop to keep the window open
It closes the program after playing the music
It initializes the pygame mixer
It loads the MP3 file
Which part of the code sets the title of the Tkinter window?
pygame.mixer.init()
root.geometry("500x300")
root.title('MP3 player')
play_button = Button(root, text="Play", font=("Helvetica", 32), command=play)
What is the role of the Label widget in this code?
To display the title "MyMusicPlayer" in the GUI
To play the music file
To close the application
To create the play button
What does the parameter loops=0 in pygame.mixer.music.play(loops=0) mean?
The music will loop infinitely
The music will play only once
The music will not play
The music will play twice
If you want to change the window size, which line should be modified?
root.geometry("500x300")
pygame.mixer.init()
root.mainloop()
pygame.mixer.music.play()
If the file "music.mp3" is missing, what will happen when the play button is pressed?
The program will still play a default song
The program will crash with an error
The program will close automatically
The play button will not work, but no error will appear
