Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9177559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:21:13+00:00 2026-06-17T17:21:13+00:00

I am attempting to write a program that calculates a certain formula based on

  • 0

I am attempting to write a program that calculates a certain formula based on zipcode, lat, and lng.

My initial idea was to create an object for each zip code.

class destination():
def __init__(self, zipcode, count):
    self.zipcode = zipcode
    self.count = count

def getCount(self):
    return self.count

def getZip(self):
    return self.zipcode

def getLatitude(self):
    return self.lat 

def getLongitude(self):
    return self.lng 

def __str__(self):
    return "%s at %s , %s" % (self.zipcode, self.lat, self.lng)

def getCoords(self):
    '''
    Must be called before getLatitude or get Longitude
    '''
    self.place, (self.lat, self.lng) = gn.geocode(str(self.zipcode))  
    self.city = self.place.split(",",1)
    self.name =  self.city[0]
    self.value = str(count)+","+self.name

    return self.value

That works fine as I can successfully iterate over a list and create the object and extract the necessary information out of i

zipList = ['54971','46383','90210']

for i in zipList:
    i = destination(i,count)
        count += 1

Will return

1,Ripon
-88.8359447
43.8422049
2,Valparaiso
-87.0611412
41.4730948
3,Beverly Hills
-118.4003563
34.0736204

What I cant seem to wrap my head around is how to set up the program so that it iterates through the list calling the haversine function with the correct information for each item.

def haversine(latStart,lonStart,latEnd,lonEnd):

Example:
if my list is

zipList = ['54971','46383','90210']

Then it will do the calculation for 54971 to 46383, 54971 to 90210, and 46383 to 90210

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:21:15+00:00Added an answer on June 17, 2026 at 5:21 pm

    Ask for all pairs of zipcodes from the list, and use them:

    import itertools
    
    for start, stop in itertools.combinations(zipList, 2):
        print start, stop
        # now pass start, stop to your function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to write a short mini-program in Python that plays around with force-based
I'm currently attempting to write my own program that mirrors the pmap command, specifically
I am attempting to write a program that utilizes a ComboBox to display currently
I am attempting to write a program that can play a list of flashes
I'm currently attempting to write a simple python program that loops through a bunch
I'm attempting to write a program that downloads Team Viewer and installs it and
I'm attempting to write a program that will generate a text file with every
I'm attempting to write a program that uses json objects to communicate and am
I am attempting to write a small recursive program that tests a list and
I have been attempting to write a program that will determine if a number

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.