Changes

Jump to: navigation, search

OPS435 Python Assignment 2 A

1,734 bytes added, 10:46, 24 July 2018
Program Name and valid command line arguments
The task for this assignment is to write a python program which will take a date in the "YYYYMMDD" format and the number of day before or after the given date as the command line arguments, and output the actual date which is the number of day before or after the given date in the same format.
 
= Due Date =
 
Assignment 2 is due Friday Aug 3. Submit on blackboard under the assignments section.
 
All your Python code for this program must be placed in a <font color='red'><b><u>single source file</u></b></font>. Please include the following declaration by <b><u>you</u></b> as a comment in your Python source code file (replace "Student Name" with your own name):
<source>OPS435 Assignment 1 - Summer 2018
Program: dbda.py
Author: "Student Name"
The python code in this file (ur.py) is original work written by
"Student Name". No code in this file is copied from any other source
including any person, textbook, or on-line resource. I have not shared
this python program with anyone or anything except for submission for grading.
I understand that the Academic Honesty Policy will be enforced and violators
will be reported and appropriate action will be taken.
</source>
= Instruction =
== Program Name and valid command line arguments ==
Name your python3 program as <code>dbda.py</code>. The program should accept two command line parameters, the first one is the date in "YYYYMMDD" format, and the second one is the number of day from the given date, a position 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 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 dbda.py 20180101 1</code></b>, and the output should be<br />
20180102
* <b><code>python3 dbda.py 20180101 2</code></b>, and the output should be<br />
20180103
* <b><code>python3 dbda.py --step 20180101 3</code></b>, and the output should be<br />
20180102
20180103
20180104
* <b><code>python3 dbda.py 20180701 500</code></b>, and the output should be<br />
20191113
* <b><code>python3 dbda.py 20189901 2</code></b>, and the output should be<br />
Error: wrong month entered
* <b><code>python3 dbda.py 20180199 2</code></b>, and the output should be<br />
Error: wrong day entered
* <b><code>python3 dbda.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 given, display the proper usage.
 
== Program structure ==
Your program code should all be in a single python file with at least two functions, one called yesterday() and the other called tomorrow():
=== Sample code for the tomorrow() function ===
<pre>
# echo Return the date in YYYYMMDD after the current given day
#
def tomorrow(today):
to_month = tmp_month + 0
tomorrow_date next_date = str(year)+str(to_month).zfill(2)+str(to_day).zfill(2)
return tomorrow_datenext_date
</pre>
198
edits

Navigation menu