Where are you calling from?

phone

Learning Objectives


By completing this challenge you will further improve your file manipulation techniques.

If you cannot remember how to open and read through a text file or CSV check our blog post about “how to access text files using Python”.

Your Challenge


Your challenge consists of writing a program that will prompt the end-user to enter their telephone number.

Your program will extract the area code for this number and search for this area code using the CSV file given to you. The program will then display the location this phone number is linked to.


TextFile
phonecodes.csv

Complete the Code


Extension


The CSV file also gives you the longitude and latitude coordinates of each area code. These coordinates can be used to calculate the distance between two sets of coordinates on the earth, using the Haversine formula. You could adapt your script to calculate the distance in miles between two UK phone numbers.

To find out more about the Haversine formula you may want to complete this challenge first: UK Postcodes distance calculator.

Share Button
Posted in Computer Science, Python - Intermediate, Python Challenges Tagged with: , ,

Our Latest Book