Purpose built micro-bit speakers can be purchased for the micro;bit. Typically they have three connections as shown in the image on the right.
from microbit import *
import music
tune = ["E4:4", "E4:4", "E4:8", "E4:4", "E4:4", "E4:8", "E4:4", "G4:4", "C4:4", "D4:4", "E4:8", "F4:4", "F4:4", "F4:4", "F4:4", "F4:4",
"E4:4", "E4:4", "E4:2", "E4:2", "E4:4", "D4:4", "D4:4", "E4:4", "D4:8", "G4:8", "E4:4", "E4:4", "E4:8", "E4:4", "E4:4", "E4:8",
"E4:4", "G4:4", "C4:4", "D4:4", "E4:8", "F4:4", "F4:4", "F4:4", "F4:4", "F4:4", "E4:4", "E4:4", "E4:2", "E4:2", "G4:4", "G4:4",
"F4:4", "D4:4", "C4:8"]
while True:
if button_a.is_pressed():
music.play(tune)