Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Python script named isValidTime.py that: a. Take 1 string as an argument and determine if it is a valid time in 12hour am/pm

Write a Python script named isValidTime.py that:

a. Take 1 string as an argument and determine if it is a valid time in 12hour am/pm format.

b. Hour must be between 1 and 12 and can have 1 or 2 digits. Minutes must be between 0 and 59 and must have 2 digits. Example: 7:35 am and 09:59 pm are valid, while 7:65 am and 15:25 pm are not valid

c. The am/pm part is valid only if both characters are uppercase, or both characters are lowercase. Example: AM, PM, am, and pm are all valid while aM, pM, Am, Pm are not valid.

d. The space between the minute portion and am/pm portion is optional. Example: 7:35am and 7:35 am are both valid.

e. If valid print valid time, otherwise print invalid time f. If there is not exactly 1 argument, print an error message and exit

This code will be run on Ubuntu.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic 4 Ole Database And Controls Superbible

Authors: Michael Hatmaker, C. Woody Butler, Ibrahim Malluf, Bill Potter

1st Edition

1571690077, 978-1571690074

More Books

Students also viewed these Databases questions