Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write this program as a menu driven program where one of the menu selections is

ID: 3624843 • Letter: W

Question

Write this program as a menu driven program where one of the menu selections is "quit" or "stop". The program is to repeatedly display the menu and process the selection until the "quit" or "stop" selection is made by the user. When the "quit" or "stop" selection is made, the program should stop.

Remember, distance=rate x time.

write a program that displays a menu allowing the user to select air,water, or steel. After the user has made a selection, he or she should be asked to enter to the number of seconds the sound will travel in the selected medium. the program should then display the distance the sound will travel

Medium Speed
Air 1,100 feet per second
Water 4,900 feet per second
Steel 16400 feet per second

Explanation / Answer

def main():
    #dictionary containing the speeds of sound in each medium
    speeds = {"air":1100,"water":4900,"steel":16400}
    while (True):
        choice = raw_input("Type a medium (air, water, or steel) or type quit to quit. ")
        if choice == "quit": break
        time = float(raw_input("Type the number of seconds the sound will be traveling. "))
        distance = time*speeds[choice]
        print "Distance traveled by the sound: %.02f feet"%(distance)

if __name__ == "__main__":
    main()