do you guys help newbies??

malik m malik_martin at hotmail.com
Wed Nov 27 06:48:56 EST 2002


hi yea i messed up here's the code sorry about the html too i was
using it through hotmail while i learnd and still am learning how to
use newsgroups....

#chapter 3 test control structures 3.3
print "hello, this program will tell me how many miles per gallon your
car drives by the \n amount of miles entered by the user along with
the size of his/her tank."

#initialize variables
totalMilesDriven = 0 #total miles driven

totalGallonsPerTank = 0 #total gallons per tank

counter = 0 #bogus counter

#processing phase
gallonsPerTank = raw_input("Enter how many gallons your tank holds, -1
to end:")
gallonsPerTank = int(gallonsPerTank)

milesDriven = raw_input("enter how many miles driven, -1 to end:")
milesDriven = int(milesDriven)

while gallonsPerTank or milesDriven != -1:
    averagea = milesDriven / gallonsPerTank
    counter = counter + 1
    print "your miles per gallon are", averagea
    totalMilesDriven = totalMilesDriven + milesDriven
    totalGallonsPerTank = totalGallonsPerTank + gallonsPerTank
    gallonsPerTank = raw_input("Enter how many gallons your tank
holds, -1 to end:")
    milesDriven = raw_input("enter how many miles driven, -1 to end:")

#termination phase
if counter != 0:
    average = float( totalMilesDriven ) / float( totalGallonsPerTank )
    print "The total miles per gallon is", average
else:
    print "No data entered"




More information about the Python-list mailing list