#Carlos Solano, Assignment 4 problem 6 Distance Traveled #Get User info carSpeed = raw_input("What is the speed of the vehicle in mph?: ") carSpeed = int(carSpeed) print carSpeed hoursTravel = raw_input("How many hours has it traveled?:" ) hoursTravel = int(hoursTravel) print hoursTravel distance = carSpeed*(hoursTravel) print "Your total distance is: ", distance, " miles" print "Hour"," ", "Distance Traveled(miles)" #A for loop is made so that the correct amount of hours are displayed including the miles associated with that hour. #add +1 so that all of the hours are displayed, and not have one missing. for hoursTravel in range(1, hoursTravel+1): print(hoursTravel), " ", hoursTravel*carSpeed
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question