# Distance traveled # This module calculates the cumulative distance a vehicle travels for each hour of a time period # Written by Beth Mela # Last updated April 23, 2015 # Ask user for the speed of the vehicle in miles per hour speed=input('Enter the speed of the vehicle in miles per hour:') print(speed) # Ask user for the number of hours the vehicle has traveled numberHours=input('Enter the number of hours the vehicle has traveled:') print(numberHours) # Display the distance the vehicle has traveled for each hour of that time period sColumns = "" for NextRow in range(1): print('Hour Cumulative Distance Traveled') print('__________________________') for nextHour in range(1,numberHours+1): distance=speed*nextHour print('{} {}'.format(nextHour,distance)) # End module
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