Created
May 7, 2015 04:31
-
-
Save gilrg18/f085b4311a9a1fe6c75d to your computer and use it in GitHub Desktop.
Cars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def car(): | |
x=open("93cars.dat.txt","r") | |
mpgc=0 | |
mpgh=0 | |
mp=0 | |
cars=0 | |
f=1 | |
for line in x: | |
if f%2==1: | |
mpgc=mpgc+float(line[52:54]) | |
#print ("mpgc",mpgc) | |
mpgh=mpgh+float(line[55:57]) | |
#print ("mpgh",mpgh) | |
mp=mp+float(line[43:46]) | |
#print ("mp",mp) | |
cars=cars+1 | |
#print ("cars",cars) | |
f=f+1 | |
#print ("f",f) | |
i=round(mpgc/cars,2) | |
j=round(mpgh/cars,2) | |
k=round(mp/cars,2) | |
return (i,j,k) | |
s=car() | |
print ("CityMPG",s[0] ,"HighwayMPG",s[1] , "AverageMidrangePrice",s[2]) | |
#GILBERTO ROGEL GARCÍA |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment