Tuesday 29 November 2016

Show the distance in miles per gallon with respect user defined value in Python.

#Show the distance in miles per gallon with respect user defined value in Python.
#input

km = float(input("Enter the distance in KM: ")) 
gallon = float(input("Enter the gas
utilisation in gallon :"))

#calculation

miles = km * 0.621
mile_per_gallon = (miles/gallon)

#print of result

print "Miles per Gallon of Given data is :",mile_per_gallon



Output 

Enter the distance in KM: 345
Enter the gas utilisation in gallon :343.66
Miles per Gallon of Given data is : 0.623421404877

2 comments:

  1. Sir instead of input can we use raw_input ,is input its alternative?

    ReplyDelete
  2. raw_input is input in a form of string only

    ReplyDelete