Question: Using python programming , and using while loopsCreate a program that will have the user enter a time, putting in the hours, minutes, and time

Using python programming , and using while loopsCreate

a program that will

have the user enter

a

time, putting in the hours,

minutes, and

time

period (AM or PM) individually

,

and in that order

.

The user must enter

valid

information for each input, and the

program must

reprompt the

user as many times as needed until they enter

valid input

for

each

q

uestion

. Once they enter valid values

for all three questions, the

program should display the time as entered by the user.

If the user enters an invalid

i

nput

, the program must tell the user

why

it is

invalid: for hours and minutes,

t

hat

w

hether

i

t

is too high or low; for time

period

, that it must be

AM

or

PM

to be correct

The input must be validated

to these specifications:

Hours must be between 1 and 12, inclusive.

Minutes must be between 0 and 59, inclusive.

T

ime period must be

AM

or

PM

, in all caps.

N

OTE

:

It is

p

erfectly

acceptable

for the program to display

3

:

7

PM

when

it

i

s

3

:0

7

PM

.

(And similar

displays

whenever minutes is less than

10.)

You

do

not

have to worry about fixing this in your program.

(See the next page for sample output.)

bash

-

4.1$ python hw3_part3.py

Please enter the time: hours, then minutes, then AM/PM

Please enter the hour:

7

Please enter

the minute:

14

Please enter the time period:

AM

It is 7 : 14 AM

bash

-

4.1$ python hw3_part3.py

Please enter the time: hours, then minutes, then AM/PM

Please enter the hour:

1

Please enter the minute:

7

Please enter the time period:

PM

It is 1 :

7

PM

bash

-

4.1$ python hw3_part3.py

Please enter the time: hours, then minutes, then AM/PM

Please enter the hour:

0

The hours value is too low.

Please enter the hour:

13

The hours value is too high.

Please enter the hour:

8

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!