DO NOT COPY FROM answers OR ANY OTHER SITES ALL ANSWER AREWRONG
ALREADY I MISSED 5 QUEASTION ALL ANSWER AREWRONG
I NEED FRESH AND NEAT ANSWER
OTHERWASE I WILL GIVE MINIMUM 5 DISLIKES ON YOURANSWER
Part A: Class Date We provide the Python program “lab11a.py” thatdemonstrates the use of the class “Date” in the module named“date.py”. In Part A of the lab, you will examine the Pythonstatements in all the files and test their behavior. Do not editthe “Date” class. 1. Download the files for this laboratoryexercise, then run the Python shell and enter the followingcommands: >>> import date >>> help( date )>>> help( date.Date ) >>> x = date.Date()>>> x >>> print( x ) 2. Consider the Pythonstatements shown below (from the file named “lab11a.py”). Using theoutput produced by the commands above, predict what the output willbe, then test your predictions by executing the statements. importdate 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( "March15, 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 (lab11a.py) to test the behavior of the memberfunction “__init__” when one or more of the arguments to thatfunction are erroneous. That is, test a date such as 13/40/2017. 4.Revise the program (lab11a.py) to test the behavior of the memberfunctions “from_iso” and “from_mdy” when the arguments to thosefunctions are strings which contains spaces. 5. Revise the program(lab11a.py) to test the behavior of the member functions “from_iso”and “from_mdy” when the arguments to those functions are erroneous.? On-line students should submit the completed program (named“lab11a.py”) for grading via the Coding Rooms system. (Note thatthere are no automatic tests for this program—your TA will grade itby hand.) Part B: Class Time You will develop a new data type tomodel the time on a 24 hour clock, where the three data membersrepresent the hour, the minutes and the seconds. Use the date.pymodule as a guide. It will be named “class Time”, and each objectof that type will have three instance variables (“__hour”, “__mins”and “__secs”). The module will be named “clock.py”. 1. Develop thefunction member (method) named “ __init__ ” which will be used toinitialize an object of type “Time” when it is created. Thatfunction will receive four parameters: a reference to the currentobject (“self”), the hour, the minutes and the seconds. a. Assumethat the last three of the four parameters are integers. b. Use adefault value of 0 for those last three parameters. c. Assign thoselast three parameters to the three instance variables. d. Add a“doc string” to the constructor documenting the purpose of thefunction. 2. Save the file containing your class as “clock.py”,then experiment with your module in the iPython shell: >>>import clock >>> help( clock ) >>> help(clock.Time ) >>> A = clock.Time() >>> A>>> print( A ) 3. Develop the function member named “__repr__ ” which will be used to display the formal representationof an object of type “Time” in the Python shell. a. Return a stringwith the format “Class Time: hh:mm:ss”. b. Be sure to place leadingzeroes in the string for the hour, minutes and seconds. c. Add a“doc string” to the constructor documenting the purpose of thefunction. 4. Save the file containing your class as “clock.py”,then experiment with your module in the iPython shell: >>>import clock >>> A = clock.Time() >>> A>>> B = clock.Time(7,12,3) >>> B # shoulddisplay: Class Time: 07:12:03 5. Develop the function member named“__str__” which will be used to display a human-readablerepresentation of an object of type “Time” in Python programs: a.Return a string with the format “hh:mm:ss”. b. Be sure to placeleading zeroes in the string for the hour, minutes and seconds. c.Add a “doc string” to the constructor documenting the purpose ofthe function. 6. Save the file containing your class as “clock.py”,then experiment with your module in the iPython shell: >>>import clock >>> A = clock.Time() >>> print( A )>>> B = clock.Time(7,12,3) >>> print( B ) 7.Develop the function member named “from_str” which will be used toupdate an object of type “Time” after it has been created. Thatfunction will receive two parameters: a reference to the currentobject (“self”) and a string of the form “hh:mm:ss”. a. Assume thatthe string parameter can be split into three integers. That is,assume that the parameter is in the format specified—no errors. b.Assign those three integers to the three instance variables. c. Adda “doc string” to the constructor documenting the purpose of thefunction. 8. Save the file containing your class as “clock.py”,then experiment with your module in the iPython shell: >>>import clock >>> A = clock.Time() >>> print( A )>>> A.from_str('07:12:03') >>> print( A )>>> A 9. We provide the Python program named“clockDemo.py” that demonstrates the use of your class “Time”. Testyour class using clockDemo.py. 10. Create a new file named “lab11b.py ” which contains the source code from the files named“clock.py” and “clockDemo.py”. That is, create a file whichcontains both the definition of class “Time” and the demonstrationprogram. The class definition should be at the top of the file. Tocreate that “stand alone” file you will need to remove (or commentout) the “import clock” line (you don’t need to import it becauseit is already in the file). Also, since you have not imported“clock” you need to change “clock.Time” to “Time”. Test that yourfile is working before submitting.Part A: Class Date We provide thePython program “lab11a.py” that demonstrates the use of the class“Date” in the module named “date.py”. In Part A of the lab, youwill examine the Python statements in all the files and test theirbehavior. Do not edit the “Date” class. 1. Download the files forthis laboratory exercise, then run the Python shell and enter thefollowing commands: >>> import date >>> help(date ) >>> help( date.Date ) >>> x = date.Date()>>> x >>> print( x ) 2. Consider the Pythonstatements shown below (from the file named “lab11a.py”). Using theoutput produced by the commands above, predict what the output willbe, then test your predictions by executing the statements. importdate 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( "March15, 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 (lab11a.py) to test the behavior of the memberfunction “__init__” when one or more of the arguments to thatfunction are erroneous. That is, test a date such as 13/40/2017. 4.Revise the program (lab11a.py) to test the behavior of the memberfunctions “from_iso” and “from_mdy” when the arguments to thosefunctions are strings which contains spaces. 5. Revise the program(lab11a.py) to test the behavior of the member functions “from_iso”and “from_mdy” when the arguments to those functions are erroneous.? On-line students should submit the completed program (named“lab11a.py”) for grading via the Coding Rooms system. (Note thatthere are no automatic tests for this program—your TA will grade itby hand.) Part B: Class Time You will develop a new data type tomodel the time on a 24 hour clock, where the three data membersrepresent the hour, the minutes and the seconds. Use the date.pymodule as a guide. It will be named “class Time”, and each objectof that type will have three instance variables (“__hour”, “__mins”and “__secs”). The module will be named “clock.py”. 1. Develop thefunction member (method) named “ __init__ ” which will be used toinitialize an object of type “Time” when it is created. Thatfunction will receive four parameters: a reference to the currentobject (“self”), the hour, the minutes and the seconds. a. Assumethat the last three of the four parameters are integers.b. Use adefault value of 0 for those last three parameters. c. Assign thoselast three parameters to the three instance variables. d. Add a“doc string” to the constructor documenting the purpose of thefunction. 2. Save the file containing your class as “clock.py”,then experiment with your module in the iPython shell: >>>import clock >>> help( clock ) >>> help(clock.Time ) >>> A = clock.Time() >>> A>>> print( A ) 3. Develop the function member named “__repr__ ” which will be used to display the formal representationof an object of type “Time” in the Python shell. a. Return a stringwith the format “Class Time: hh:mm:ss”. b. Be sure to place leadingzeroes in the string for the hour, minutes and seconds. c. Add a“doc string” to the constructor documenting the purpose of thefunction. 4. Save the file containing your class as “clock.py”,then experiment with your module in the iPython shell: >>>import clock >>> A = clock.Time() >>> A>>> B = clock.Time(7,12,3) >>> B # shoulddisplay: Class Time: 07:12:03 5. Develop the function member named“__str__” which will be used to display a human-readablerepresentation of an object of type “Time” in Python programs: a.Return a string with the format “hh:mm:ss”. b. Be sure to placeleading zeroes in the string for the hour, minutes and seconds. c.Add a “doc string” to the constructor documenting the purpose ofthe function. 6. Save the file containing your class as “clock.py”,then experiment with your module in the iPython shell: >>>import clock >>> A = clock.Time() >>> print( A )>>> B = clock.Time(7,12,3) >>> print( B ) 7.Develop the function member named “from_str” which will be used toupdate an object of type “Time” after it has been created. Thatfunction will receive two parameters: a reference to the currentobject (“self”) and a string of the form “hh:mm:ss”. a. Assume thatthe string parameter can be split into three integers. That is,assume that the parameter is in the format specified—no errors. b.Assign those three integers to the three instance variables. c. Adda “doc string” to the constructor documenting the purpose of thefunction. 8. Save the file containing your class as “clock.py”,then experiment with your module in the iPython shell: >>>import clock >>> A = clock.Time() >>> print( A )>>> A.from_str('07:12:03') >>> print( A )>>> A 9. We provide the Python program named“clockDemo.py” that demonstrates the use of your class “Time”. Testyour class using clockDemo.py. 10. Create a new file named “lab11b.py ” which contains the source code from the files named“clock.py” and “clockDemo.py”. That is, create a file whichcontains both the definition of class “Time” and the demonstrationprogram. The class definition should be at the top of the file. Tocreate that “stand alone” file you will need to remove (or commentout) the “import clock” line (you don’t need to import it becauseit is already in the file). Also, since you have not imported“clock” you need to change “clock.Time” to “Time”. Test that yourfile is working before submitting.
OTHERWASE I WILL THUMBSDOWN YOUR ANSWER DONT FORGETSURLY I WILL DISLIKE AND REPORT YOUR ACCOUNT
hi team
DO NOT COPY FROM answers OR ANY OTHER SITES ALL ANSWER ARE WRONG ALREADY I MISSED 5 QUEASTION ALL ANSWER ARE WRONG I NEED
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am