1. Download the file(DATE LOCATED AT THE BOTTOM) for this laboratory exercise, t
ID: 664206 • Letter: 1
Question
1. Download the file(DATE LOCATED AT THE BOTTOM) for this laboratory exercise, then run the Python shell and enter the following commands:
>>> import date(located at the bottom)
>>> help( date )
>>> help( date.Date )
>>> x = date.Date()
>>> x
>>> print( x )
Consider the Python statements shown below. Using the output produced by the commands above, predict what the output will be, then test your predictions by executing the statements.
import date(located at the bottom)
A = date.Date( 1, 1, 2014 )
print( A )
print( A.to_iso() )
print( A.to_mdy() )
print( A.is_valid() )
print() B = date.Date( 12, 31, 2014 )
print( B ) print( B.to_iso() )
print( B.to_mdy() )
print( B.is_valid() )
print()
C = date.Date()
C.from_iso( "2014-07-04" )
print( C )
print( C.to_iso() )
print( C.to_mdy() )
print( C.is_valid() )
print()
D = date.Date()
D.from_mdy( "March 15, 2015" )
print( D )
print( D.to_iso() )
print( D.to_mdy() )
print( D.is_valid() )
print()
E = date.Date()
print( E )
print( E.to_iso() )
print( E.to_mdy() )
print( E.is_valid() )
print()
3. Revise the program(above) to test the behavior of the member function “__init__” when one or more of the arguments to that function are erroneous.
4. Revise the program(above) to test the behavior of the member functions “from_iso” and “from_mdy” when the arguments to those functions are strings which contains spaces.
5. Revise the program(above) to test the behavior of the member functions “from_iso” and “from_mdy” when the arguments to those functions are erroneous.
DATE.py:
Explanation / Answer
CONCEPT:
TO UNDERSTAND THE GIVEN CODE BEHAVIOUR
Answers:
1.for this I have downloaded code from the bottom of questions
2.for the print statements these are the output's
1-1-2014
2014-01-01
January 01,2014
true
2014-12-31
December 01,2014
true
2014-07-04
2014-07-04
July 04,2014
true
2015-03-15
2015-03-15
March 15,2015
true
null
null
null
null
space
3.when we pass errorneous data as input it will shows the error
4.when we pass spaces included data AS input it will shows the error
4.when we pass errorneous data input it will shows the error
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.