This is an individual assessment competency hurdle task. If you have questions or need help, ask privately on the forums. Students caught working together will be awarded an automatic fail.
Instructions
- Write a python function as described in the logic requirements below.
- Your work must meet the following coding standards requirements:
- All variables must be in lowerCamelCase style
- Indentation must be in four space = 1 tab style
- Any use of 'except' must be followed by a specific error being trapped.
- Function headers are required to be defined using docstrings on the line following the function definition and must contain a short description (two lines max) of the function, parameters (explicit) and returns (explicit). If there are none, this must be specified.
- A file header is required. This must be the first 3 lines of the document using the normal commenting style, and must contain the author name, last modified date, file version number.
- When ready, attend your scheduled assessment slot and get your work marked off. If you fail to complete or meet the requirements of any item/part, you will be marked as not satisfactory and be required to return in the following week to re-attempt it.
- Completing this task within the first three weeks of assessment (i.e. week 4-6) will award 'second chance' bonus marks of 2% which can be used to 'make up' for marks lost from the project.
- Failing to complete this task by week 12 will result in an automatic fail of the unit with a mark cap of 45%. A late completion penalty of 5% will apply if you fail to complete this within the four week assessment period (week 4-7).
- Students who miss attempts (scheduled assessment period) due to valid special consideration reasons (unwell, etc) can request for a late completion penalty waiver by emailing eng1013.clayton-x@monash.edu with the reason and evidence.
In-Person Assessment Requirements
- Your completed code (as a .py file) on your computer.
- You will need to also pass an interview and discussion about your work.
Logic Requirements
Write a python program to calculate the penalty for speeding in Victorville using the conditions in the table provided below. Note that the conditions in the table shown are not in the correct sequence - conditional statements must be written in the right order, so make sure you read all of the conditions and then decide on the most appropriate order for them.
Your program will need to contain two sections, a main() function and a determine_overspeed_penalties() function.
main()
The main() function has no parameters and contains the logic as follows:
- Ask the user if they are driving a heavy vehicle or not
- Ask the user for the road speed limit in km/h (integer values only)
- Ask the user for their vehicle speed in km/h to two decimal places
- Perform the required validation for the three items above to ensure that the user only provides valid values. If an invalid input was provided, the program should print an appropriate error message and ask the user for a new value for that input.
- Call the determine_overspeed_penalties() function and provide the inputs above as parameters
- Using the dictionary returned by the function determine_overspeed_penalties(), print the following information out appropriately (e.g. if no penalties apply, you should state so)
- The vehicle overspeed value in km/h to three decimal places
- Any penalties that apply (only show the penalty that applies)
- Then, ask the user if they would like to check for another vehicle (Y/N)
- If they respond with 'Y', restart the program
- If they respond with 'N', end the program
- Otherwise, if they respond with anything else, ask for a new input (must only accept Y or N as valid inputs here)
At any time, if the user hits CTRL+C (Keyboard Interrupt), the program should end after printing 'Exiting program now'.
determine_overspeed_penalties()
The determine_overspeed_penalties() function has the three parameters vehType, roadSpeed, speedLimit:
- vehType should be a boolean variable containing True if the vehicle is heavy.
- roadSpeed should be an float variable containing the vehicle speed.
- speedLimit should be a integer variable containing the road speed limit.
The function should contain the logic as follows:
- Determine the overspeed value which is calculated by taking the vehicle speed and subtracting the road speed limit from it.
- Using the tables below, determine the appropriate penalties that apply. In determining penalties, you should round the overspeed value up to the nearest integer (i.e. 23.1 rounds up to 24.0).
- If the vehicle is not speeding (overspeed <= 0), the dictionary should return 0 for overspeed with appropriate values for penalties.
- Return a dictionary containing the keys as follows:
- overspeed: float value containing the original overspeed value calculated
- penalties: a list containing the following three values - demerits (integer), suspension (integer), fines due (float).
Penalties for speeding offenses (except heavy vehicles)
Exceeding the speed limit | Penalty | Demerit points | Automatic licence suspension |
---|
By less than 10 km/h | $247.00 | 1 | - |
10 km/h to under 25 km/h | $395.00 | 3 | - |
25 km/h to under 30 km/h | $543.00 | - | 3 months |
30 km/h to under 35 km/h | $642.00 | - | 3 months |
35 km/h to under 40 km/h | $741.00 | - | 6 months |
40 km/h to under 45 km/h | $840.00 | - | 6 months |
By 45 km/h or more | $988.00 | - | 12 months |
20 km/h to under 25 km/h (in a 110 km/h zone) | $395.00 | - | 3 months |
Penalties for speeding offenses - heavy vehicles
Exceeding the speed limit | Penalty | Demerit points | Automatic licence suspension |
---|
By less than 10 km/h | $324 | 1 | - |
10 km/h to under 15 km/h | $509 | 3 | - |
15 km/h to under 25 km/h | $740 | 3 | - |
25 km/h to under 30 km/h | $1,017 | - | 3 months |
30 km/h to under 35 km/h | $1,294 | - | 3 months |
35 km/h to under 40 km/h | $1,572 | - | 6 months |
40 km/h to under 45 km/h | $1,849 | - | 6 months |
By 45 km/h or more | $2,127 | - | 12 months |
20 km/h to under 24 km/h (only in a 110 km/h zone) | $740 | - | 3 months |