<
Python Coding

Back to Coding Stuff Page

Python your WAY - no hello world examples on this page ....dots are for indentation (not part of code)

Program will ask you 3 questions.
1. how many exercises? example 10
2. how many times you want to do it? for 30 seconds each
3. harp or gong sound between each 30 seconds? gong sound
So you can do 10 exercises and at every 30 seconds a gong sound will play and let you know to do the next exercise.



import winsound
import os
import time


#can the computer play sound?
try:

....winsound.Beep(400, 1000)
except RuntimeError:
....print("The system is not able to beep the speaker")
except ImportError:
....print("Can't import winsound module")


# winsound.PlaySound('Harp1.wav' , winsound.SND_ASYNC)


#Variables

global howlong
global interval
global soundf

# howlong = int(input("Please enter How long (60 to 1800 seconds):"))
howmany = int(input("Please enter How many exercises :"))
interval = int(input("Please enter How Repeat Time (15 to 300 seconds):"))
x = int(input("Play: 1=harp 2=gong:"))
if x == 1:
....soundf = "Harp1.wav"
else:
....soundf = "Chinesegong1.wav"

# howlong = 60
# interval = 10


def executeTimeLoop():
....winsound.PlaySound(soundf , winsound.SND_ASYNC)
....#winsound.Beep(400, 1000)
....time.sleep(interval)

howlong = howmany * interval


while howlong > 0:
....print (howlong)
....howlong = howlong - interval
....executeTimeLoop()

winsound.Beep(400, 1000)





Email comments to: Webmaster@23cyber.com*****© 2013 23cyber.com All Rights Reserved.....Something very special.....