In [3]:
import math as ma
from haversine import flight_distance
from airport_data import airports
from airport_coords import coordinates
import draw_flight
%matplotlib inline

no_flights_string = raw_input('Type the number of flights flown in a year:')
no_flights = int(no_flights_string)
assert no_flights > 0, "You have not flown any flights!"
assert no_flights < 1000, "Number of flights must be an integer!"
flight = 1
total=0
x1,x2,x3,x4, origin, destination = coordinates()
distance=flight_distance(x1,x2,x3,x4)
while no_flights != 0:
    #origin_destination_airports = raw_input("Please enter the origin and destination airports (separated by a comma) for flight number "+str(flight)+".").split(',')
    #assert len(origin_destination_airports) == 2, 'This entry should be made of 2 airport names (strings), separated by comma!'
    #assert type(origin_destination_airports) == <type 'list'>, "This entry should be made of 2 airport names (strings), separated by comma!: %r" % origin_destination_airports
    #stopover_airports = raw_input("Please enter all stopover airports (separated by a comma) for flight number "+str(flight)+". If it was a direct flight (with no stopovers), please press number 0:").split(',')
    #assert type(stopover_airports) == <type 'list'>, "This entry should be made of all airport stopovers (as strings), separated by comma!: %r" % stopover_airports
    #if str(stopover_airports[0]) == '0':
     #   print 'DIRECT FLIGHT!'                             #The code for calculating distance between aiports should go here
    
    
        
    #if str(stopover_airports[0]) != '0':
     #   no_flight_legs=len(stopover_airports)+1          #The number of flights between stopover airports is the no_airports plus one!
      #  flight_leg = 1
  #      while no_flight_legs != 0:
   # 
    #                          #The code for calculating distance between aiports should go here
     #       if flight_leg == 1: print 'Distance for flight number '+str(flight)+', flight leg '+str(flight_leg)+', between '+origin_destination_airports[0]+' and '+stopover_airports[flight_leg-1]+' is '# + str(distance_between_aiports) This should show distance between individual airports 
      #      if flight_leg > 1 and flight_leg == len(stopover_airports)+1: print 'Distance for flight number '+str(flight)+', flight leg '+str(flight_leg)+', between '+stopover_airports[flight_leg-2]+' and '+origin_destination_airports[1]+' is '# + str(distance_between_aiports) This should show distance between individual airports 
       #     if flight_leg > 1 and flight_leg < len(stopover_airports)+1: print 'Distance for flight number '+str(flight)+', flight leg '+str(flight_leg)+', between '+stopover_airports[flight_leg-2]+' and '+stopover_airports[flight_leg-1]+' is '# + str(distance_between_aiports) This should show distance between individual airports 
        #    flight_leg = flight_leg + 1
         #   no_flight_legs = no_flight_legs - 1
    print 'Total distance for flight number ',str(flight),' is ' ,distance #str(Total) This should show distance flown for the whole flight trip (sum of all flights between all stopovers)
    flight = flight + 1
    no_flights = no_flights - 1
    total = total + distance
print 'The total distance flown in a year is ' ,total #str(total_distance) This should be the sum of all the flights

draw_flight.draw(x1,x2,x3,x4)


Type the number of flights flown in a year:1
Where are you flying from? LAX
Where are you flying to? LHR
 Coordinates for Los Angeles International [ LAX ] are (Lat / Lon): 33.9425 / -118.407222
Coordinates for London Heathrow [ LHR ] are (Lat / Lon): 51.469722 / -0.451389
Total distance for flight number  1  is  8754.72651221
The total distance flown in a year is  8754.72651221

In [3]:
print str(flight_leg)
print len(stopover_airports)


2
1

In [ ]: