Given the time of day in terms of an hour, minute, second and "day half" (i.e., AM or PM), write a Python function named

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Given the time of day in terms of an hour, minute, second and "day half" (i.e., AM or PM), write a Python function named

Post by answerhappygod »

Given The Time Of Day In Terms Of An Hour Minute Second And Day Half I E Am Or Pm Write A Python Function Named 1
Given The Time Of Day In Terms Of An Hour Minute Second And Day Half I E Am Or Pm Write A Python Function Named 1 (21.91 KiB) Viewed 29 times
Given The Time Of Day In Terms Of An Hour Minute Second And Day Half I E Am Or Pm Write A Python Function Named 2
Given The Time Of Day In Terms Of An Hour Minute Second And Day Half I E Am Or Pm Write A Python Function Named 2 (34.01 KiB) Viewed 29 times
Given The Time Of Day In Terms Of An Hour Minute Second And Day Half I E Am Or Pm Write A Python Function Named 3
Given The Time Of Day In Terms Of An Hour Minute Second And Day Half I E Am Or Pm Write A Python Function Named 3 (16.6 KiB) Viewed 29 times
Given the time of day in terms of an hour, minute, second and "day half" (i.e., AM or PM), write a Python function named fraction_of_day to calculate and return (not print!) the fraction of the day (a value of type float) that has elapsed since midnight (12:00 AM). For example, fraction_of_day (12, 0, 0, 'A') would evaluate to 0.0. fraction_of_day (12, 0, 0, 'p') would evaluate to 0.5 fraction_of_day (11, 59, 59, 'p') would evaluate to 0.999988426 Hints: Convert the time into seconds since midnight. You must also handle the 12:00AM case specially.
Write a main function that produces the following neatly formatted table using f- strings for formatted printing. You solution must use looping to print the table. You will get no credit for a solution that uses, say, 24 variables and/or 24 print statements instead of a loop. Time 12:00 AM 1:00 AM 2:00 AM 3:00 AM 4:00 AM 5:00 AM 6:00 AM 7:00 AM 8:00 AM Fraction Since Midnight 0.0000 0.0417 0.0833 0.1250 0.1667 0.2083 0.2500 0.2917 0.3333
9:00 AM 10:00 AM 11:00 AM 12:00 PM 0.3750 0.4167 0.4583 0.5000 1:00 PM 0.5417 2:00 PM 0.5833 3:00 PM 0.6250 4:00 PM 0.6667 5:00 PM 0.7083 (Your solution should continue to 11pm)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply