加油站

来源:互联网 发布:联淘宝 编辑:程序博客网 时间:2024/04/27 17:46

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

 

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)*zif 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: 60precent of full:  40km per liter: 10You can get another   240.0   kmThe next gas station is 200 km awayYou can wait for the next station>>> 

 

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



 

原创粉丝点击