: def main():
: #declare and initialize variables
technically you never "declare" variables in python, you just bind names to values.
: #AIR as constant
: AIR = 1100
: #WATER as constant
: WATER = 4900
: #STEEL as constant
: STEEL = 16400
I'm sure you know by now, but these aren't true "constants". Python has no such construct.
: #prompt user for distance of travel
: feet = input("Now, please enter the distance that the sound wave will travel(feet): ")
input() is risky because it tries to eval() whatever the user enters so can very easily trigger exceptions. Better to use raw_input and try to convert the value to a decimal.
: #calculate time for sound to travel
: A = AIR
: W = WATER
: S = STEEL
All you've done here is make two names both equal the same value A and AIR are now both references to the same integer object.
: if MenuChoice == A:
: seconds = feet / AIR
: elif MenuChoice == W:
: seconds = feet / WATER
: MenuChoice == S
: seconds = feet / STEEL
The user entered strings, but here you're checking their input against the value of A. A is different than 'A' in Python.
: #display ETA of the sound
: print "\nIt will take", seconds, "second(s) for the sound wave to travel."
Like I mentioned in the other reply, you need to call your main function after defining it.
Ok, so here is what I have come up with:
#This program will calculate the time it will take a sound to travel based on
#the matter it is traveling through; air, water, or steel.
# sound propagation "constants"
AIR = 1100
WATER = 4900
STEEL = 16400
print "WELCOME TO THE SPEED OF SOUND PROGRAM!!!"
print "I will calculate the time it takes for a souond to travel through"
print "different matter."
#build menu for user to choose from
print "Please choose from the following menu:\n"
#prompt user for choice
choice = ' '
while choice not in 'AaWwSs':
choice = raw_input("\nPlease enter your choice here (A, W, S): ")
#prompt user for distance of travel
feet = float(
raw_input("Please enter the distance (feet) that the sound wave will travel: ")
#calculate time for sound to travel
seconds = 0
if choice in 'Aa':
seconds = feet / AIR
elif choice in 'Ww':
seconds = feet / WATER
elif choice in 'Ss':
seconds = feet / STEEL
#display ETA of the sound
print "\nIt will take", seconds, "second(s) for the sound wave to travel."
if __name__ == '__main__':
$ select * from users where clue > 0
no rows returned