Jump to content

Python Music/Sound Code record for killing piece in favor or against the computer

Featured Replies

Hi,

Kindly guide me some code for producing sound or music which I can use for indicating that a computer piece has been killed or the computer has killed the piece. Small file just executable for 2 or 3 secs. I am working in text mode.

 

Zulfi.

55 minutes ago, zak100 said:

Kindly guide me some code for producing sound or music which I can use for indicating that a computer piece has been killed or the computer has killed the piece. Small file just executable for 2 or 3 secs. I am working in text mode.

print("\a")

The line of code plays the bell sound, which differ from environment to environment.
It fulfils the requirements stated in OP: It is some code, producing sound or music. It is a small file (one line) and these type of sound files (where files are used) in the OS are usually small and contains a few seconds of sound. It works in text mode*; there will be a visible bell if audio is disabled in the terminal.

 

*) I made a guess what "I am working in text mode" means.

Edited by Ghideon
explanation added and improved

  • Author

Hi,

Thanks all, I had a very short time but appreciate your efforts. Any other would definitely benefit from it. However, I used only : print("\a"). This was a great experience. I have once developed cross and zero game but 8-board game proved very lengthy for me and I did it using Python. Definitely this experience woul help me if I learn some ML skills also in Python.

 

God blesses you all.

 

Zulfi.

Archived

This topic is now archived and is closed to further replies.

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.