Beeping Alarm Function I'm trying to create an alarm function with Python3. The below code does work but it doesn't seem like this is the most optimal way of achieving something like this. Is there a more pythonic way?

#!/usr/local/bin/python3

import os
import time

def alarm():
    os.system('amixer -D pulse sset Master 30%')     # &gt;&gt; Set initial volume
    for beep in range(0, 20):
        time.sleep(.002)
        os.system('play --no-show-progress --null --channels 1 synth %s sine %f' % (.08, 2500))

alarm()
Pythonic approach

For sound playback in Python, see this discussion.
Avoid os.system

If you are forced to use it, supply a fully qualified path to the executable. You never know what weird program called play may be in the search path prior to an intended one.
Modularize

As written, the code is not reusable. An attempt to import it would result in an immediate alarm sound. Put the call to alarm in an

if __name__ == '__main__':


clause.
Avoid magic numbers

All the parameters (beep duration, volume, etc) better be passed via a command line (see sys.argv and optparse module).
Dummy variable

is customarily denoted as _:

    for _ in range(20):