Question: write a python code In the Functions 2 lecture, you had a Do this now question like: Jerry's car's speedo shows miles (mph) instead of
In the Functions 2 lecture, you had a "Do this now" question like: Jerry's car's speedo shows miles (mph) instead of kilometres per hour (kph). He wants to be able to enter his speed in mph, the speed limit in kph and determine his speeding fine. You (we) wrote the pseudocode for the main function for this: function main speed_in_mph = get_valid_number("speed in mph) speed_limit_in_kph = get_valid_number("speed limit in kph) speed_in_kph - convert_miles_to_kn speed_in_mph) fine = determine_finespeed_in_km, speed limit_in_kph) print fine Note: The value of the fine as a number type is much better to return than a string, or a whole message What if we wanted to determine a new bank balance after paying the fine? bank_balance - fine This is an example of SRP. It is the determine_fine function's ONLY (single responsibility) job to determine calculate the actual fine as an actual number It is counter-productive for this function to print the fine or to format with a 's' or anything else, bank_balance -- fine doesn't work it fine is something like your fine is $199. Write the complete Python program for this in Jerry.py Remember that you've done some of this before, so copy your previous work Prac 2 where we calculated km ->m Prac 3 where we determined speeding fines Note that we only want to know the fine as a number, not the demorit points or any other messages
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
