tank_size = float(raw_input("How many liters of gas can your tank hold when full? ")) percent_full = float(raw_input("What persentage of your tank is full? ")) km_per_liter = float(raw_input("How many kilometers can you travel per liter of gas? ")) km_left = ((tank_size/100)*percent_full)*km_per_liter print "You can go another", km_left, "kilometers." print "The next gas station is 200 km away." if km_left >= 400: print "You can wait to get gas at the gas station after this one. You have a lot of gas!" if km_left >= 200 and km_left < 400: print "You can wait for the next station, but don't wait until the one after that!" if km_left < 200: print "Get gas now!"
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