Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

GUI MP3 Player (Grade 9)

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Which library is used in the code to create the graphical user interface (GUI)?

a)

pygame

b)

tkinter

c)

random

d)

os

2.

What is the purpose of pygame.mixer.init() in the code?

a)

To create a window for the MP3 player

b)

To load the MP3 file into memory

c)

To initialize the pygame mixer for playing audio

d)

To change the background color

3.

What does the function play() do in this code?

a)

It opens a new Tkinter window

b)

It closes the program

c)

It stops the music playback

d)

It loads and plays the MP3 file

4.

What does the play_button do in the program?

a)

Starts playing the music

b)

Closes the MP3 player

c)

Changes the title of the window

d)

Adjusts the volume

5.

What does root.mainloop() do in this program?

a)

It runs the Tkinter event loop to keep the window open

b)

It closes the program after playing the music

c)

It initializes the pygame mixer

d)

It loads the MP3 file

6.

Which part of the code sets the title of the Tkinter window?

a)

pygame.mixer.init()

b)

root.geometry("500x300")

c)

root.title('MP3 player')

d)

play_button = Button(root, text="Play", font=("Helvetica", 32), command=play)

7.

What is the role of the Label widget in this code?

a)

To display the title "MyMusicPlayer" in the GUI

b)

To play the music file

c)

To close the application

d)

To create the play button

8.

What does the parameter loops=0 in pygame.mixer.music.play(loops=0) mean?

a)

The music will loop infinitely

b)

The music will play only once

c)

The music will not play

d)

The music will play twice

9.

If you want to change the window size, which line should be modified?

a)

root.geometry("500x300")

b)

pygame.mixer.init()

c)

root.mainloop()

d)

pygame.mixer.music.play()

10.

If the file "music.mp3" is missing, what will happen when the play button is pressed?

a)

The program will still play a default song

b)

The program will crash with an error

c)

The program will close automatically

d)

The play button will not work, but no error will appear