14:长途旅行中,刚到一个加油站,距下一个加油站还有200Km,而且以后每个加油站之间距离都是200km 编写一个程序确定是不是需要在这里加油,还是可以等到接下来的第几个加油站再加油 。

# -*- coding:utf-8 -*-
#Quetion:
#长途旅行中,刚到一个加油站,距下一个加油站还有200Km,而且以后每个加油站之间距离都是200km
#编写一个程序确定是不是需要在这里加油,还是可以等到接下来的第几个加油站再加油
#程序询问以下几个问题:
#1)你车的油箱多大,单位升
#2)目前油箱还剩多少油,安百分比计算,比如一半就是0.5
#3)你的车没升油可以走多远(Km)
#提示:油箱包含5升的缓冲油,以防油表不准
#Tank_size :油箱大小
#surplus_oil:剩余油量
#per_L_journey:一升油走多少路
#History :
# 2018/05/17 Murphy First Release  Python_version 2.7


Tank_size = float (raw_input("How much litre is your tank size ?: "))
surplus_oil =  float(raw_input("How much litre do you have ?: "))
per_L_journey = float(raw_input("How long per litre does your car run ?: "))
if 200<(surplus_oil + 5)*per_L_journey < 400:
    print "You don't need to stop at this station."

elif (surplus_oil + 5)*per_L_journey < 200:
    print "Your oil is not enough for the next station. Please add iol at this station ."

猜你喜欢

转载自blog.csdn.net/sinat_18722099/article/details/80356818
今日推荐