Assignment 01

Assignment 1 – Getting Started in Python

Outcomes

  • Set up Python Programming Environment
  • Write your first program

Assignment

You will first want to ensure your Python Environment is operational.  In the materials section below I recommend using the Anaconda Framework and the Spyder editor.

Once complete you will write a Python File to allow the user to enter any 2 sets of UTM coordinates and calculate the distance and bearing from the first to the second coordinate.

Generate an Engineering Report (see guidelines) with the solution and the methodology used to solve the problem – which will include the code you wrote to accept input, perform calculations, and produce formatted output.

You will get the UTM Coordinates from the discussion boards.

Materials

Lecture 1 – Videohttps://youtu.be/mKwCsrwAVrg –  Shows working in the Python environment to solve problems and also a little about distance and bearings. 

Anaconda Download – https://www.anaconda.com/download/  – Download and install the full Anaconda for your environment. You will use the Spyder editor for this course. You will obviously need Python.

Python Tutorial – https://www.w3schools.com/python/default.asp – You will need to complete the tutorial up through operators and also conditions. This tutorial is one of the best I have found.

UTM Coordinateshttps://www.maptools.com/tutorials/utm/quick_guide – Since you are solving in a real-world coordinate system, it is probably best to know a little about UTM Coordinates. 

The Lectures Page has more video and information on the programming for this and all the other assignments. You should look at the lectures available.   

Use the discussion boards to freely ask questions and discuss resources to help you complete this assignment. Also if you find other resources to help with the assignment or learn Python, please post them and I will add them to the assignments. 

Testing Your Function

You will likely want to test the function that calculates the bearing. So if you write the function as

def calculateBearings(e1,n1,e2,n2)

Where e is east and n is north and the direction is from 1 to 2. Now when entering the following numbers for e1,n1,e1,n2 you should get the following bearings.

calculateBearings(0,0,1,1) - should give 45 degrees
calculateBearings(0,0,1,-1) - should give 135 degrees (90 + 45)
calculateBearings(0,0,-1,-1) - should give 225 degrees (180 + 45)
calculateBearings(0,0,-1,1) - should give 315 degrees (270 + 45)

This should help you test your function. If this works, there is a good chance it is a solid function. This is called a test case. A function call where the answer is known to help you determine if a function works correctly.