Question: SUBMIT original code in Python to solve the problem belon. Please be aware that copring and pasting code from any other source other than code
SUBMIT original code in Python to solve the problem belon.
Please be aware that copring and pasting code from any other source other than code you have explicitly written on your own is considered plagiarism. fyou receive help, that is fine document help in the comments of your code however you need to write your own code, name your own variables, and comment your own code. Students turing in the exact same work as another student will all be given zeros. Plagiarism is not tolerated, and students found to be plagiarizing will be given a zero and reported to the University with the possibility of termination of the class and degree program.
Write a program that asks the user to enter a distance number, and the unit of distances, either KM kilometers or MI miles and then converts that distance to the other metric:
If the user enters a number and KM the output should be the entered distance converted to miles
If the user enters a number and MI the output should be the entered distance converted to kilometers
You can use the following formula for conversion:
Miles Kilometers X
Kilometers Miles X
The requirement for your program is as follows:
Both conversions must be written as functions to be called by the main program
The program must handle incorrect inputs from users. Specifically, the user must type in correct float numbers in the first input, and either KM or MIcasesensitive in the second input. Incorrect inputs should not cause errors and instead should trigger a new request to the user to type again until the input is correct.
In the below example, highlighted texts are from the program, and bolded texts are inputs from users.
Example :
Please enter a float number:
Please enter a unit: KM
The entered distance is Miles
Example :
Please enter a float number:
Please enter a unit: MI
The entered distance is Kilometers
Example :
Please enter a float number: abdfs
Please enter a correct float number:
Please enter a correct float number:
Please enter a unit:
KM
The entered distance is Miles
Example :
Please enter a float number:
Please enter a unit: abc
Please enter a correct unit KM or MI :
Please enter a correct unit KM or MI: KM
The entered distance is Miles
Hint: please review input validation to do this assignment. You can validate the two inputs separately to make it less complicated.
Upload your source file and screenshots of outputs to DL
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
