加油站

简单的输入输出  强制类型转换   课后题

 

x=float(raw_input("Size of tank: "))
y=float(raw_input("precent of full:  "))
z=float(raw_input("km per liter: "))
p=x*(y/100)*z
if p>=200:
  print "You can get another  ",p,"  km"
  print "The next gas station is 200 km away"
  print "You can wait for the next station"

else:
     print "You can get another  ",p,"  km"
     print "The next gas station is 200 km away"
     print "Get gas now"


输入出结果:

 

>>> ================================ RESTART ================================
>>> 
Size of tank: 60
precent of full:  40
km per liter: 10
You can get another   240.0   km
The next gas station is 200 km away
You can wait for the next station
>>> 

 

>>> ================================ RESTART ================================
>>> 
Size of tank: 60
precent of full:  30
km per liter: 80
You can get another   1440.0   km
The next gas station is 200 km away
You can wait for the next station



 

你可能感兴趣的:(加油站)