Changes

Jump to: navigation, search

OPS435 Online Assignment 1

118 bytes added, 20:18, 25 June 2020
Script structure and sample template
= Assignment Requirements =
== The First Milestone (due June 19) ==
* 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].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 a1_template.py. 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 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 Assignment (due July 3) ==
* As stated before, your code will be inside the file "a1_[studentid].py". The first step will be to clone the Assignment 1 repository. The invite link will be provided to you by your professor. Once you clone the repository, run this command: "cp a1_template.py a1_[studentid].py". (Replace studentid with your myseneca username). Begin writing the content that is required. Additional requirements are outlined below.
== The Debrief (due July 10) ==
This document, like the algorithm document, will be submitted to Blackboard one week after the assignment. Answer the following questions:
* Research Python modules that you could have used to accomplish the same goals as the today() and leap_year() functions.
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 two dates in "YYYYDD-MM-DDYYYY" format, a positive or negative integer, and return a an integer that corresponds to the number of days between the given dates. If the start date either before or after is earlier than the given stop date according to , the value of number is positive. If start date is later than the given integer in stop date, the same formatnumber is negative. Your dbda() function should delegate the actual calculation of the target date to either the after() function or the before() function.
* The today() function will be called if the user has not specified a second argument. It will return '''your Linux computer's local time''' in the format DD-MM-YYYY. Hint: you may need to read man pages for a shell command in order to return a usable date. You may also use string formatting to modify output.
* 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)+"-"+str(to_month).zfill(2)+"-"+str(to_dayyear).zfill(2)
return next_date

Navigation menu