Software Design and Implementation
T10: Oh, the Places You'll Go!
Today is your day!
Your mountain is waiting,
So... get on your way!”
Assignment T10 should be completed in a pair programming partnership, generally two students.
Objectives
- Learn to use tuples and lists
- Understand how geographical coordinates work
Assignment Specifics
This assignment is to be completed in pairs in
class.
In this team assignment, we are going to learn about where you are from, where you have visited, and where you'd like to go. To do this, we are going to leverage two data types: tuples and lists. Using the tuples and lists you create, we will use our friend, the turtle library, to create a map for you and your partner. But first, some background.
Latitude and LongitudeLatitude and longitude are geographic coordinates which can describe any single location on Earth. The planet is segmented into vertical and horizontal slices; vertical slices are called longitudes, while horizontal slices are called latitudes. Using these two values together, we can pinpoint any place on Earth by referencing a map:

Image courtesy of: http://adelswart.files.wordpress.com/2000/01/a1465-global_latitude_longitude.gif
Lines of latitude, or horizontal lines, can take a value between +90 ° and -90 °, with 0° representing the Equator.
Lines of longitude, or vertical lines, can take a value between +180° and -180°, with 0° representing the Prime Meridian.
Curious where you are in the world? This website will let you put in an address and it will provide you with your geographic coordinates: http://universimmedia.pagesperso-orange.fr/geo/loc.htmz
For this assignment, you and your partner will use latitude and longitude to plot specific places on a map:
- Where both of you are originally from
- Any place you've visited, or would like to visit, in your lifetime
You will then plot those locations onto a world map. Each partner will get two colors: one color for places they've visited, one color for their home. Each place will also get some text printed next to each item to let us know more about that location.
Tuples vs Lists
Syntactically, tuples are Python data structures which use ( ) as the syntactic container, and lists are data structures which use [ ] as the syntactic container, but what other differences are there? Tuples are immutable, while lists are mutable, but what exactly does that mean?
Once you create a tuple, you cannot edit it; it is immutable. Lists on the other hand are mutable, you can edit them. With lists, you can also add items and delete items; but you can't do either with a tuple, because tuples have a fixed size once they are created. As a consequence of this mutability difference, accessing data in tuples can be faster.
In addition, lists are most typically used with homogenous collections of data. The reason for this has to do with performance as well, namely the underlying memory management of how the data is accessed in the actual memory. Tuples are most often used with both homogenous and heterogenous collections of related data which are related to one another, but which do not change (e.g., name and place of birth). By heterogeneous, the items contained in a tuple often express different related concepts, while the items in a list typically all belong to the same semantic category [e.g., a list of places].
Instructions for this Assignment
- Download the following starter code and background image: places.zip
- Unzip the folder. Make sure to keep the program and the image files in the same folder as you code.
- Modify the code to include the following:
- Create a new tuple for each location you've visited (or would like to visit), and your home. Each tuple should contain the following elements, in order:
- Your name
- The name of the location
- The latitude of the location
- The longitude of the location
- Whether you've visited/will visit that location ("visit"), or that location is your home ("home")
- Create a list containing all the tuples created above.
- Using the place_pin() function, iterate through the list of places and drop a pin on the map. The place_pin() function is already built for you; you only need to build the loop and correctly call the function.
- By the way, you will see "TODO markers" in the comments of this program. Programmers, particularly those working in teams, often place TODO markers in their code which serves as a reminder for tasks that *need* to be completed. Many Integrated Development Environments (IDEs), including PyCharm, Eclipse, and Visual Studio just to name a few, will recognize and highlight TODO markers in a special way. We are using them to mark what you need to complete for this teamwork.
- Be sure to use meaningful variable names.
- Complete the descriptive header as a comment at the top of your source code.
- Note that to represent a single place, we used a tuple, but to represent all the places, we used a list. With your partner, discuss these two data structures, when one is more applicable than the other, and why. After discussing with your partner, create a word document named yourusernames-t10.docx and answer the following questions:
- When is a tuple a more appropriate data structure to use than a list? Briefly explain.
- When is a list a more appropriate data structure than a tuple? Briefly explain.
- Tuples are immutable; lists are mutable. Would lists have been better for representing a single place, and tuples better for representing all places? Or did Dr. Scott and Dr. Jan use the most appropriate data structures for each? Justify your response by explaining your answer.
- Consider another problem: representing patient data for hospital records (i.e., patient name, date of birth, social security number, health records...). Which data structure is more appropriate for this problem? Again, briefly justify your answer.
- If you finish the requirements before the end of class, please modify your map to make it even more amazing: add new colored markers, add new classifications of places, add new text... explore!
- The driver should upload yourusernames-t10.py to Moodle. Be sure all contributors to the assignment are acknowledged in the header block.
- The navigator should upload yourusernames-t10.docx to Moodle. Again, be sure all contributors names are on the assignment.