What is winsound.MessageBeep() in Python 3?
Overview
The winsound module in Python 3 provides an interface to interact with the sound playing machinery in Windows. The MessageBeep function plays a built-in Windows sound. The syntax of the MessageBeep function is as follows:
winsound.MessageBeep(type=MB_OK)
Parameters
typeis awinsoud.MB_value that specifies which system sound to play. The following table summarizes the sounds available:
winsound Values |
Corresponding Control Panel Sound |
|---|---|
MB_ICONASTERISK |
Asterisk |
MB_ICONEXCLAMATION |
Exclamation |
MB_ICONHAND |
Critical Stop |
MB_ICONQUESTION |
Question |
MB_OK |
System Default |
Note: If
-1is passed, then a default beep is played.
Return value
MessageBeepreturnsNone.
Example
The following code provides an example of how to use the MessageBeep function:
import winsoundwinsound.MessageBeep(winsound.MB_ICONHAND)
In the example above, the Critical Stop built-in sound is played using the MessageBeep function.
Free Resources
Copyright ©2026 Educative, Inc. All rights reserved