Changes

Jump to: navigation, search

OPS435 Assignment 1 for Section C

6,043 bytes removed, 14:25, 9 October 2020
no edit summary
The preliminary code should look like this:
<b><code><pre>
Hostname: NeoMex
Kernel Release: 5.4.0-48-generic
Mem [======== ] 40 %
Swap [= ] 3 %
</pre></code></b>
In addition, you will be expected to build on this capability with some relevant functions.
= Assignment Requirements =
== Permitted Modules ==
<b><font color='blue'>Your python script is allowed to import only the <u>os, subprocess and sys</u> modules from the standard library and all the built-in functions.</font></b>
== Required Functions ==
= Submission Guidelines =
The first step will be to clone the Assignment 1 repository. The invite link will be provided to you by your professor. The repo will contain a check script, a README file, and the file where you will enter your code.
 
== The First Milestone (due October 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]algorithm.txt'''. This file should be plaintextand located in your GitHub repository. The document will contain two sections: * A description of how you plan to implement the "afterpercent_to_graph()" function works. The "after()" function is provided to you in a1_templateThis explanation should be line-by-line.py. Open the file, and use clear English You will be graded based on your attention to describe what line of code does in such a way that a competent programmer could reproduce the code without seeing it firsthanddetail. * You will then apply A description of how you plan to implement the same principles to create an algorithm for "before()", and "dbda()"required output overall. Inside Consider the code, if input you are calling another function like "leap_year"working with, and consider the output you may simply describe what need to present. Break the function will returnproblem down into smaller problems, and not the operation of the function itselfconsider any issues you might encounter. * This file You will be submitted to Blackboard a week after graded on evidence that you have considered the assignment goes livetask, and should be your but not on "getting it right the first prioritytime. The object of the milestone is not to " * Once you have a 100% perfect algorithmcompleted this file, but add it to plan ahead and anticipate challenges and issues with the assignmentyour GitHub repository. The milestone will also give your professor an opportunity for feedbackUse <code>git add algorithm.* [https:txt<//simple.code>, then <code>git commit -m"added algorithm.wikipedia.orgtxt"</wikicode> and <code>git push</Algorithm Here is an basic introduction to Algorithm]* While you are working on the step-by-step instructions, note that there are different number of days in each month and some years have 365 days and some years have 366 dayscode>.* 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 November 32, 11:59pm) ==* As stated before, your code will be inside the file "a1_[studentid]assignment1.py". The first step will be to clone Begin by completing the Assignment 1 repositoryrequired functions, committing your changes as you go. The invite link will be provided Complete and test each function before moving to you by your professorthe next. Once * When you clone have completed the repositorytask, run this command: "cp a1_templatemake sure that all your changes have been committed and pushed to GitHub.py a1_[studentid]<b>In addition, you will submit <code>assignment1.py". (Replace studentid with your myseneca username). Begin writing the content that is required. Additional requirements are outlined below</code> to Blackboard.</b>
== The Debrief (due November 12) ==
This document, like part of the algorithm document, assignment will be submitted to Blackboard one week after completed under GitHub's "Issues" tab. * Your professor will examine the assignmentcode and post questions under "Issues". Answer the following questions:for full credit of your work.* Research Python modules that you could have used Create new issues to accomplish answer the same goals as the today() and leap_year() functions. following questions: * Which solution is preferableIs your code portable, in terms of performanceie. have you tested on other Linux machines? Which solution is preferable, in terms of programmer hoursHow can we make programs portable? (which solution would take longer for a programmer to implement?) * Which approach would be preferable in Why did you choose the "real world"? Why is it useful to try creating our own algorithmadditional features that you did? * What challenges did you encounter during the assignment, and what resources did you use to solve your issues? (help from classmates, help from Stackoverflow, debuggers, etc.)* Additionally, your professor may have questions specific to your submission. You should answer these questions as well.    == Tests and Test results ==You must name your python 3 script as <code>a1_[Student_id].py</code>. The following examples assumes that the student_id is rchan.The script should accept two command line arguments, the first one is the date in "YYYY-MM-DD" 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 optional flag called --step which can be provided at the command line that makes the program print out all dates until the target date. If the "YYYY-MM-DD" format is broken, your script should 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 a1_rchan.py 01-01-2019 02-01-2019</code></b>, and the output should be<br /> 1* <b><code>python3 a1_rchan.py 01-01-2019 31-12-2018</code></b>, and the output should be<br /> -1* <b><code>python3 a1_rchan.py 01-06-2020</code></b>, and since today is June 3, the output should be<br /> 2 * <b><code>python3 a1_rchan.py 01-01-2019 01-01-2020</code></b>, and the output should be<br /> 365* <b><code>python3 a1_rchan.py 01-01-2021 01-01-2020 </code></b>, and the output should be<br /> -366* <b><code>python3 a1_rchan.py 01-13-2018</code></b>, and the output should be<br /> Error: wrong month entered* <b><code>python3 a1_rchan.py 99-01-2020 01-01-2020</code></b>, and the output should be<br /> Error: wrong day entered* <b><code>python3 a1_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 arguments given, display the proper usage:* <code>Usage: a1_rchan.py DD-MM-YYYY [DD-MM-YYYY] >/code> == Script structure and sample template == 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 two dates in "DD-MM-YYYY" format, and return an integer that corresponds to the number of days between the given dates. If the start date is earlier than the stop date, the number is positive. If start date is later than the stop date, the number 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 "DD-MM-YYYY" format and return the date of the previous day in the same format.* The after() function will take a date in "DD-MM-YYYY" 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 "DD-MM-YYYY" 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 DD-MM-YYYY after the given day# def after(today): if len(today) != 10: return '00-00-0000' else: str_day, str_month, str_year = today.split('-') year = int(str_year) month = int(str_month) day = int(str_day)  lyear = year % 4 if lyear == 0: feb_max = 29 # this is a leap year else: feb_max = 28 # this is not a leap year  lyear = year % 100 if lyear == 0: feb_max = 28 # this is not a leap year  lyear = year % 400 if lyear == 0: feb_max = 29 # this is a leap year  tmp_day = day + 1 # next day  mon_max = { 1:31, 2:feb_max, 3:31, 4:30, 5:31, 6:30, 7:31, 8:31, 9:30, 10:31, 11:30, 12:31} if tmp_day > mon_max[month]: to_day = tmp_day % mon_max[month] # if tmp_day > this month's max, reset to 1 tmp_month = month + 1 else: to_day = tmp_day tmp_month = month + 0  if tmp_month > 12: to_month = 1 year = year + 1 else: to_month = tmp_month + 0  next_date = str(to_day)+"-"+str(to_month).zfill(2)+"-"+str(year).zfill(2) return next_date</pre>
= Rubric =
= Due Date and Final Submission requirement =
 
Check with your professor for the due date for your section.
Please submit the following files by the due date:
* [ ] your algorithm document, named as 'algorithm_usernamealgorithm.txt', to Blackboardin your GitHub repo, by October 19.* [ ] your python script, named as 'a1_[seneca-id]assignment1.py', should be included in your repository, and also '''submitted to Blackboard.'''* [ ] the output of the checking script checkA1.py, named as 'a1_output.txt', should be included in your repositoryby November 2 at 11:59pm.* [ ] your debrief document answers should be submitted as issues to BlackboardGitHub by November 12.

Navigation menu