Lab 02
Lab 02: Python Fundamental Part 02
This lab covers the fundamentals of Python data, including topics such as loop, while and functions.
There are three questions in total. Please provide your code answers directly below each question.
Make sure to run all cells so that the answers are stored. Once completed, export your .ipynb file as either HTML or PDF, ensuring that all answers are included. Submit the HTML or PDF file to Canvas by midnight (11:29 PM) on September 15.
This lab is worth a total of 65 points and contributes 6.5% toward the final grade.
Q1. Write a function to provide student's grade in letter. (20 points)
If student's score range from 100 - 80 then return A, range from 79-60 then return B, below 60 then return C
The function should:
- Take one arguments: score in number
- Return the score in letter (A,B, or C)
You output should like below:
Q2. Write a function to return the latitude and longitude coordinates for one of the 3 parks in Worcester. (25 points)
- Take one arguments: park name
- Return the latitude and longitude of the park
- If input argument is not in the dictionary, return 'Park not found'
You output should like below:
# Use below dictionary to finish Q2
parks = {
'Elm':"42.269, -71.815",
'Wetherell':"42.273, -71.823",
'Institude':"42.277, -71.803"
}
Q3. Write a function to check whether a given latitude is valid (between -90 and 90 degrees). If the input is not a number, it will catch the error and handle it. (20 points)
- Take one arguments: latitude
- Return a message to tell user if the given latitude is valid
- If input argument is not in the correct type, return "Error: Invalid input. Please enter a numeric value for latitude."
You output should like below: