starting = raw_input ("Please enter the starting l/100km:") ending = raw_input ("Please enter the ending l/100km:") starting = int (starting) ending = int (ending) #Processing print (" l per 100km MPG") print ("-------------------------------") for l_per_100km in range (starting,ending+1): mpg = 287.5 / l_per_100km mpg = float (mpg) print "%5i" % l_per_100km, "%12i" % mpg
trying to get MPG to output as float
trying to get MPG to output as float
|
Mar-24-2018, 10:10 AM
on line 12 you should use
"%12f" That said, you should use python3, not python2 use str.format() method or f-strings (available in python 3.6). check also https://docs.python.org/3/library/string...matstrings
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link Create MCV example Debug small programs
Mar-24-2018, 12:15 PM
hey thanks very much i hafe to use python 2 because of the course im on uses it.
|
|
Users browsing this thread: 1 Guest(s)