Changes

Jump to: navigation, search

OPS445 Online Assignment 1

204 bytes added, 09:14, 28 September 2022
m
Command Line Argument to be supported
== Required Files ==
<!--<b>NOTE: It's not necessary to download these files if you are cloning a repository provided by your professor!</b>-->There are two files that we are providing to youwithin the assignment repository [clone it to get these files]:* <!--[https://ict.senecacollege.ca/~eric.brauer/ops445/a1/assign1.py assign1.py] --> '''assign1.py''' - contains starter code for your assignment. You should commit all of your code to this file.* <!--[https://ict.senecacollege.ca/~eric.brauer/ops445/a1/checkA1.py checkA1.py] --> '''CheckA1.py''' - is a check script that will help you evaluate your assignment. For full marks, your assignment should pass all checks.
== The First Milestone - BB only!!! (Due October 14Oct 07) ==* Before you begin programming, it is important to plan your algorithm. Therefore your first task will be to complete and submit an algorithm document. This document should be named '''algorithm_[student_id]algorithm_youruserid.txt'''. This file should be plaintext. The document will contain two sections:
* A description of how the "after()" function works. The "after()" function is provided to you in the assign1.py template. Open the file, and use clear English to describe what line of code does in such a way that a competent programmer could reproduce the code without seeing it firsthand.
* You will then apply the same principles to create an algorithm for "before()", and "dbda()".
* This file will be submitted to Blackboard a week after the assignment goes live, and should be your first priority. The object of the milestone is not to have a 100% perfect algorithm, but to plan ahead and anticipate challenges and issues with the assignment. The milestone will also give your professor an opportunity for feedback.
* [https://simple.m.wikipedia.org/wiki/Algorithm Here is an a basic introduction to Algorithm]* While you are working on the step-by-step instructions, note that there are different number numbers of days in each month and some years have 365 days and some years have 366 days.
* You should also do some research to find out when we started using the Calendar in the current form. (This will pose a limit on the validity of your algorithm.)
== The Second Milestone (Due October Oct 21) ==
For the second milestone, you will be asked to have committed the following functions inside the assign1.py file inside your repository:
* before()
It's not necessary to submit these functions to Blackboard. If you have pushed the commits correctly, the changes will be visible to your professor.
== The Assignment (Due November Nov 4) ==
* As stated before, your code will be inside the file "assign1.py". The first step will be to clone (or create) the Assignment 1 repository. Further instructions will be provided by your professor. Additional requirements are outlined below.
<b><font color='blue'>Your python script is allowed to import only the <u>sys</u> module from the standard library, and only to handle command line arguments.</font></b>
Based on the algorithm you have designed for this assignment, you should at least have the following four three functions defined in your python script (see later section on the purpose of each function) in order to get a passing grade for this assignment:
* dbda()
* after()
* before()
You should also create additional functions to improved improve the re-usability of your python code by adding the following functions to earn the maximum possible mark for this assignment:
* days_in_mon()
* leap_year()
=== Command Line Argument to be supported ===
* You will are provided with a file called assign1.py.
* Be sure that this python script has your name and student_id set inside the docstring.
* Your python script must support one or two command -line arguments only: the first should be a valid date in DD-MM-YYYY format and the second an integer (negative or positive).
* If there are no arguments, more than two arguments, or an invalid date, your script should display the correct usage message and exit.
=== Authorship Declaration ===
All your Python code for this assignment must be placed in a <font color='red'><b><u>single source python file</u></b></font>. Please complete the declaration <b><u>as part of the docstring</u></b> in your Python source code file (replace "Student Name" and "Student ID" with your own nameand student id respectively).
=== Github Commits ===
The following is a brief description of each function:
* The '''dbda() ''' function should be the main function of your script. The dbda() function will take a date in "YYYYDD-MM-DDYYYY" 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. Your dbda() function should delegate the actual calculation of the target date to either the after() function or the before() function. * The '''before() ''' function will take a date in "YYYYDD-MM-DDYYYY" format and return the date of the previous day in the same format.* The '''after() ''' function will take a date in "YYYYDD-MM-DDYYYY" format and return the date of the next day in the same format. Next paragraph is a sample python code for the after() function. To earn the maximum possible mark for the assignment, you should modify the sample after() function to make use of the days_in_mon() function.* The '''leap_year() ''' function will take a year in "YYYY" format, and return True if the given year is a leap year, otherwise return False.* The '''valid_date() ''' function will take a date in "YYYYDD-MM-DDYYYY" format, and return True if the given date is a valid date, otherwise return False plus an appropriate status message. The valid_date() function should make use of the days_in_mon() function.* The '''days_in_mon() ''' function will take a year in "YYYY" format, and return a dictionary object which contains the total number of days in each month for the given year. The days_in_mon() function should make use of the leap_year() function.* The '''usage() ''' function will take no argument and return a string describing the usage of the script.
=== Sample code for the after() function ===
<pre>
# Return the date in YYYYDD-MM-DD YYYY after the given day
#
def after(today):
if len(today) != 10:
return '000000-00-000000'
else:
str_yearstr_day, str_month, str_day str_year = today.split('-')
year = int(str_year)
month = int(str_month)
to_month = tmp_month + 0
next_date = str(yearto_day).zfill(2)+"-"+str(to_month).zfill(2)+"-"+str(to_dayyear).zfill(2)
return next_date
Please submit the following files by the due date:
* [ ] your algorithm document, named as 'algorithm_usernamealgorithm_youruserid.txt', to Blackboard. This is your first milestone.* [ ] your python script, named as 'assign1.py', should be included in your repository, and also '''submitted to Blackboard.'''* [ ] the output of the checking script checkA1'CheckA1.py-f -v &>', named as 'a1_resultsa1_output.txt', should be included in your repository.
572
edits

Navigation menu