Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This question concerns the construction of a doctest test script for a Python fu

ID: 652414 • Letter: T

Question

This question concerns the construction of a doctest test script for a Python function by using execution path analysis. The purpose of this function is to accept a string value as a parameter and determine whether it is a valid representation of a 12 hour clock reading. The string is a valid representation if the following applies:

- It comprises 1 or 2 leading digits followed by a colon followed by 2 digits followed by a space followed by a two letter suffix.

- The leading digit(s) form an integer value in the range 1 to 12.

- The 2 digits after the colon form an integer value in the range 0 to 59.

- The suffix is

Explanation / Answer

//describe the basic timing

#!/usr/bin/python

import time;

localtime=time.asctime(time.localtime(time,time()))

print "Local current time:",localtime

___________________________________

OUTPUT

__________________________________

Local current time: Mon Apr 15 17:24:11 2015

_____________________________________________

Structure of time function

Index

Attributes

Values

0

tm_year

2015

1

tm_mon

1 to 12

2

tm_mday

1 to 31

3

tm_hour

0 to 23

4

tm_min

0 to 59

5

tm_sec

0 to 61

6

tm_wday

0 to 6 (0 is Monday....)

7

tm_yday

1 to 366

8

tm_isdst

-1 , 0 , 1

>>> from timeutil.parser import parse
>>> value='Thu, 13 Apr 2015 18:59:18 GMT'
>>> x = parse(value)
>>> print x
2015-04-13 18:59:18+00:00

Index

Attributes

Values

0

tm_year

2015

1

tm_mon

1 to 12

2

tm_mday

1 to 31

3

tm_hour

0 to 23

4

tm_min

0 to 59

5

tm_sec

0 to 61

6

tm_wday

0 to 6 (0 is Monday....)

7

tm_yday

1 to 366

8

tm_isdst

-1 , 0 , 1

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote