Python control structure exampe program
$10-30 USD
Paid on delivery
Comparing Times
Write a function called time_compare that will have 4 parameters. These four integers represent 2 times, that is hour and minute of the first time, then the hour and minute of the second time. It returns an integer, which will be 0, 1 or 2. 0 means the two times were the same. 1 means that the first time came before the second one. 2 means the first time came after the second one.
Example calls:
compare(1,2,3,4) would return 1 because 1:02 comes before 3:04.
compare (12, 19, 12, 1) would return 2 because 12:19 comes after 12:01.
compare (3, 4, 3, 4) would return 0 because they are the same time.
Each function that returns a value uses ONE return statement at the bottom of the function definition. Use a variable to hold the return value until execution is done in the function, then return that variable.
The compare function does NOT do any input from the keyboard or output to the screen. Its interaction with the rest of the program is through its parameters and its return value.
compare the two hours first. If they are different, you have your answer without having to look at the minutes at all.
You do NOT want to write a main function for this program. Instead, open your file in your IDE. in the shell, type in a call to the function, like "time_compare(12,15,15,3)". This means you want to compare times 12:15 and 15:03. The result should be a 1.
Develop 4 test cases for this program. Example: "first time comes after second time, hour1 after hour2", 13, 20, 8, 15 (as inputs), expected return value is 2. List them in the program file as comments at the bottom of the file
Small project looking to spend around $10
Project ID: #8764275
About the project
Awarded to:
Hi Sir/Madam, I'm expert in Python programming and I can help You with this task in no time. Best regards, Fejs.
10 freelancers are bidding on average $15 for this job
HI Contact me for an efficient, perfect, well documented development of your project according to 100% accuracy and requirements, with dedicated support. Thanks
Hello An easy thing. Not really much to say. I can have this done for you in a couple minutes. Let me know if you are interested. Kind Regards Martin
Hello! I've been using python for a number of years, and I can handle this project for you right away. Thanks for your consideration! -Chris
hello, if you don't need any error checking then IT IS DONE. give me your email and I will send the file right now
I am willing to do it quickly and have it to you as soon as possible. I can do it cheaply as well. Email me if you would like me to do this for you. Thanks.