Changes

Jump to: navigation, search

OPS435 Python Assignment 1 2018 Fall

263 bytes added, 10:04, 2 October 2018
no edit summary
</pre>
= Due Date This Assignment is due on Sunday October 14, 2018 before mid-night. Please submit your python script together with test result on blackboard under the assignments section. Authorship Declaration ==All your Python code for this program assignment must be placed in a <font color='red'><b><u>single source file</u></b></font>. Please include the following declaration <b><u>as the docstring</u></b> in your Python source code file (replace "Student Name" with your own name):
<source>OPS435 Assignment 1 - Fall 2018
Program: [student_id].py (replace student_id with your Seneca User name)
</source>
= Instruction === Program Name Tests and valid command line arguments Test results ==Name You must name your python3 program python 3 script as <code>a1_[Student_id].py</code>. The following examples assumes that the student_id is rchan.The program script should accept two command line parametersarguments, the first one is the date in "YYYYMMDD" format, and the second one is the number of day from the given date, a positive value indicates the number of days after the given date, and a negative value indicates the number of days before the given date. There is an option called --step that makes the program print out all dates until the final target date. If the "YYYYMMDD" format is broken give an appropriate error message. Invalid months (>12) or invalid days of month(different for each month), should be detected and give appropriate error messages. For examples:* <b><code>python3 rchana1_rchan.py 20180101 1</code></b>, and the output should be<br />
20180102
* <b><code>python3 rchana1_rchan.py 20180101 -1</code></b>, and the output should be<br />
20171231
* <b><code>python3 rchana1_rchan.py 20180101 2</code></b>, and the output should be<br />
20180103
* <b><code>python3 rchana1_rchan.py --step 20180101 3</code></b>, and the output should be<br />
20180102
20180103
20180104
* <b><code>python3 rchana1_rchan.py 20180701 500</code></b>, and the output should be<br />
20191113
* <b><code>python3 rchana1_rchan.py 20189901 2</code></b>, and the output should be<br />
Error: wrong month entered
* <b><code>python3 rchana1_rchan.py 20180199 2</code></b>, and the output should be<br />
Error: wrong day entered
* <b><code>python3 rchana1_rchan.py 2018 2</code></b>, and the output should be<br />
Error: wrong date entered
If there is too few or too many command line parameters arguments given, display the proper usage.
== Program Script structure and sample template ==Your program code should all be in a single python file with at least the functions mentioned above: leapyeardbda(), maintomorrow(), tomorrowand yesterday(). You can also add additional functions like: leapyear(), validdate(), yesterdayusage():, etc
* The dbda() function will take a date in "YYYYMMDD" format, a positive or negative integer, and return a date either before or after the given date according to the value of the given integer in the same format.
* The yesterday() function will take a date in "YYYYMMDD" format and return the date of the previous day in the same format.
* The tomorrow() function will take a date in "YYYYMMDD" format and return the date of the next day in the same format. Next paragraph is a sample python code for the tomorrow() function.
* The leapyear() function will take a year in "YYYY" format, and return True if the given year is a leap year, otherwise return False.
* The main() function will take a date in "YYYYMMDD" format, a positive or negative integer, and return a date either before or after the given date according to the value of the given integer in the same format.
* The validdate() function will take a date in "YYYYMMDD" format, and return True if the given date is a valid date, otherwise return False.
* The yesterdayusage() function will take a date in "YYYYMMDD" format no argument and return the date of the previous day in the same format. * The tomorrow() function will take a date in "YYYYMMDD" format and return string describing the date usage of the next day in the same format. Next paragraph is a sample python code for the tomorrow() functionscript
<pre>
#!/usr/sbin/env python3
....
def dbda(yyyymmdd,days): ... setup loop call tomorrow or yesterday as appropriate return target_day  if __name__ == "__main__":
.. processing command line arguments ..
.. set loop based on the number of days given .. call tomorrowdbda() or yesterday() as appropriate
...
output the expected date
return next_date
</pre>
= Due Date =
 
This Assignment is due on Sunday October 14, 2018 before mid-night. Please submit your python script together with test result on blackboard under the assignments section.
1,760
edits

Navigation menu