Python代写:CSC108H Admissions System

代写Python基础作业,实现一个学分管理系统。

How to start

  1. Read everything in this page thoroughly. Understanding the problem is a large part of this assignment.
  2. Download and unzip the starter code.
  3. Open admission_functions.py in Wing 101.
  4. Try running checker.py in Wing 101.
  5. Write the docstring for each function. You should be able to complete the assignment with materials from Weeks 1-3.
  6. Write and test each function, using checker.py after writing each function. You can look at admission_program.py to see how the functions you are writing are called.
  7. You should be able to run admission_program.py after completing all functions.
  8. Before submitting on MarkUs, run the checker.py

Admissions System

In this assignment, you will write functions that might appear in a system used by post-secondary institutions to determine which students to admit. Some functions are required to manage a special situation that affects some students.

Goals of this Assignment

  • Use the Function Design Recipe to plan, implement, and test functions.
  • Write function bodies using variables, numeric types, strings, and conditional statements. (You can do this whole assignment with only the concepts from Weeks 1, 2, and 3 of CSC108.)
  • Learn to use Python 3, Wing101, provided starter code, a type-check module, and other tools.

Background Information

In this section, we describe a scenario to help explain what the program you will be writing does. Since we assume you have only been programming for a few weeks, we have made some adjustments to the code you will implement that are unrealistic but that make the problem easier to solve. We encourage you to pay attention to details and requirements you find unrealistic, and consider what you would need to be able to do to improve your program. You can read more about this in the “Going Further” section.

Most post-secondary institutions use some kind of computer system to help manage admissions. Often, these programs are used to handle straightforward admissions cases, freeing up human time to work on the more complex ones. The purpose of the system you are working on is to determine if students meet cutoffs for admission to degree programs and for consideration for scholarships.

Admission to degrees is based on marks in high school courses a student has taken. In our admission program, we are given two marks for every course in a student’s application. The first mark is their grade on coursework, and the second is their grade on the final exam. Their final mark in the course is the average of those two marks.

In the 2017-2018 academic year, post-secondary institutions in Alberta needed to update their admissions systems to handle a special group of incoming students. In April 2017, a strike by the Alberta Teacher’s Association (the union that represents Alberta teachers) caused many disturbances in the province’s schools. Although most schools went back to normal operations after the one-month strike, the schools in Fort McMurray, a city in northern Alberta, were not able to recollect themselves quick enough because of the resources being used on recovering from the Fort McMurray forest fires of the previous year. This included students who were in their final year of high school, preparing to write final exams. Due to all of these factors, most students were not able to write their exams.

To accommodate students in this special situation, post-secondary institutions in Alberta changed the admission criteria for these students; they would be admitted based on their coursework marks up to the evacuation, and not on the coursework plus exam mark typically used. These special criteria were only applied to students who came from particular schools in the affected year, and only if they were unable to write the exam.

Our Admission Process

This section describes the process our admission system will use.

Admission to a degree is based on the average of a student’s final mark in up to three high school courses. The admission program contains a set of courses that can be used; not every course a student submits can necessarily be used for admission. Courses that cannot be used for admission are not included in the computed average.

Each degree has its own cutoff for admission. Additionally, students whose average is 5% or more above the admission cutoff receive a scholarship. For example, if a degree has an admission cutoff of 80% then students with averages of 85% or more receive a scholarship.

Each student application is a record consisting of the name of the student, the high school they attended, their graduation year, the three courses they wish to use for admission, and the degree they are applying to.

The admission system reports, for each student, the admission decision for their application to a particular degree. If a student applies for more than one degree, the system will have more than one record for them.

Terminology and Data

In this section, we define some of the information used in the admission system, and describe how the information is represented in the program.

  • student record: A student record consists of the student’s name, the high school they attended, their graduation year, a course record for each of the three courses they wish to use for admission, and the name of the degree they are applying to. In the Assignment 1 program, a student record is represented by a string, with each piece of information separated by a comma. You will see examples of student records in the provided code. You may assume that student records will only contain commas to separate information, and that you do not need to handle the case where a record is not properly formatted. The following is an example of a student record: Jacqueline Smith,Some High School,2016,MAT,90,94,ENG,92,NE,CHM,80,85,BArts
  • course record: A course record consists of a course code, a coursework mark, and an exam mark. In the Assignment 1 program, a course record is represented by a string, with each piece of information separated by a comma. For this assignment, you can assume that each mark is exactly two characters; for example, 9 and 100 are not possible marks. A course record with a missing exam mark will contain ‘NE’ in place of the exam mark. (NE stands for No Exam.) ‘MAT,90,94’ and ‘ENG,92,NE’ are examples of course records.
  • transcript: A transcript consists of three course records. In the Assignment 1 program, a transcript is represented by a string, with each course record separated by a comma. ‘MAT,90,94,ENG,92,NE,CHM,80,85’ is an example of a transcript.
  • course code: A course code is a string of three characters that represents a course. Any string of three characters (other than a comma) is a valid course code. ‘MAT’ and ‘ABC’ are examples of course codes.
  • degree: To avoid confusion between a computer program and an academic program of study, we use the word “degree” when referring to an academic program of study. In the rest of this handout, the word “program” refers to a computer program. For this assignment, the degree a student applied to is the last part of information in their student record: all of the characters after the last comma. The characters representing a degree may appear elsewhere in a student record. For example, a student may be named ‘Arthur’ even if ‘Art’ represents a possible degree. ‘BArts’ and ‘BSci’ are examples of degrees.

Files to download

All of the files that you need to download for the assignment are in this zip file. These files must be unzipped, and folder structure not changed. Download the files by right-clicking on the link and using your web-browser’s “Save as” option. Do not use “cut and paste” as sometimes this can cause undesirable formating characters to be added to Python code.

  • Starter code is code that we provide for you to revise and turn into a complete assignment solution. The starter code for this assignment is in a file named admission_functions.py. Complete it by following the instructions in the What to do section of this handout (see below).
  • The main admissions program is in a file named admission_program.py. It is complete and must not be changed. More details on this code are given below.
  • The A1 checker code is in a file named checker.py. Download and save this file. It is complete and must not be changed. More details on this code are given below.

What to do

In the starter code file admission_functions.py, complete the function definitions for the functions listed in the table below. Use the Function Design Recipe that you have been learning. We have included the type contracts in the table; please read through the table to understand how the functions will be used. You can also take a look at the code in admission_program.py to see how the functions are used.

We will be marking your docstrings in addition to your code. Please include two examples in your docstrings. You will need to paraphrase the full descriptions of the functions to get an appropriate docstring decscription.

Examination of the provided admission_functions.py starter code file will show that it starts with the definition of some named constant variables which refer to the two schools and the year to which the special criteria apply, and a complete docstring for the is_special_case function. In your Assignment 1 solution, do not change the code that we have provided. You are to add your Python statements to this starter code file and fulfill the requirements listed in the table below.

If you examine admission_program.py, you will notice that only five of the six functions below are called in that file. The sixth function will be called by one of the functions you write, and there will be some marks allocated for correctly determining the usage.

Using Constants

Your code should make use of the provided constants. If the value of one of those constants were changed, and your program rerun, your functions should work with those new values. We will test your code using different special case schools and year by updating the values of the constants - your code should still work with this updated special case!

Your docstring examples can reflect the values of the constants in the provided starter code, and do not need to change if we change the values of the constants.

You should also create your own constants and use those in place of literal strings like ‘NE’ or ‘accept’ in your code.

What NOT to do

Your admission_functions.py file should contain the starter code, plus the function definitions specified above. Your admission_functions.py file must not include any calls to function print or input. Also, do not include any extra code outside of the function definitions, and do not import any modules.

Want to earn a good mark? Test your work!

You should carefully verify your code before submitting to determine whether it works: the Test step of the Function Design Recipe is particularly important for assignments. Once the deadline has passed, we will run our own set of tests on your submission.

To test your work, you should call on each function with a variety of different arguments and check that the function returns the correct value in each case. This can be done in the shell or using another .py file, but must not be done in your submitted admission_functions.py file.

CSC108 A1 Checker

We are providing a checker module (checker.py) that tests two things:

  • whether your functions have the correct parameter and return types, and
  • whether your code follows the Python and CSC108 style guidelines.

To run the checker, open checker.py and run it. Note: the checker file should be in the same directory as your admission_functions.py, as provided in the starter code zip file. You can find a demo of the checker being run in the Week 3 Prepare exercises on PCRS.

If the checker passes

  • Your function parameters and return types match the assignment specification. This does not mean that your code works correctly in all situations. We will run additional tests on your code once you hand it in, so be sure to thoroughly test your code yourself before submitting.
  • Your code follows the style guidelines.

If the checker fails, carefully read the message provided

  • It may have failed because one or more of your parameter or return types does not match the assignment specification, or because a function is misnamed. Read the error message to identify the problematic function, review the function specification in the handout, and fix your code.
  • It may have failed because your code did not follow the style guidelines. Review the error description(s) and fix the code style. Please see the PyTA documentation for more information about errors.

Make sure the checker passes before submitting.

Going Further (optional, not for marks)

This assignment is designed to be doable with only the concepts we see in the first few weeks of the course. This means that there are a lot of choices we made in designing this system that could be improved on as we learn more concepts. You are encouraged to think about ways in which you could improve the entire system (both the functions and program files) with additional concepts.

You will notice that there is code in admissions_program.py that we have not yet talked about in class. If you are finding this assignment pretty straightforward, we encourage you to figure out how the program code works, and to then think about how to improve it. By the end of this course, you will be able to understand all of the code in admissions_program.py, and likely even be able to think of ways to improve it! You may also think of better ways to represent the data in the program.

Important: Your code will be evaluated on how it meets the function descriptions above. While we encourage you to think about how to improve the program, do NOT submit these improvements as part of your Assignment 1 submission.

Marking

These are the aspects of your work that will be marked for A1:

  • Correctness (70%): Your functions should perform as specified. Correctness, as measured by our tests, will count for the largest single portion of your marks. Once your assignment is submitted, we will run additional tests, not provided in the checker. Passing the checker does not mean that your code will earn full marks for correctness.
  • Coding style (20%): Make sure that you follow the Python style guidelines that we have introduced and the Python coding conventions that we have been using throughout the semester. Although we don’t provide an exhaustive list of style rules, the checker tests for style are complete, so if your code passes the checker, then it will earn full marks for coding style with one exception: docstrings may be evaluated separately. For each occurrence of a PyTA error, a 1 mark (out of 20) deduction will be applied. For example, if a C0301 (line-too-long) error occurs 3 times, then 3 marks will be deducted.
  • Readability (10%): Your variable names should be meaningful and your code as simple and clear as possible. Where possible, you should avoid duplicate code by calling other functions within the module as helpers. You should use constants rather than “magic” values. Your functions should be written so that they would work properly even if different values are used for the constants. We want to see great docstrings. Again, follow the Python style guidelines.
  • One exception to the style guide: Lines in your docstring examples that contain student records (and only these lines) may exceed the 80 character limit.

What to Hand In

The very last thing you do before submitting should be to run the checker module one last time. Otherwise, you could make a small error in your final changes before submitting that causes your code to receive zero for correctness.

Submit your admission_functions.py file on MarkUs according to the instructions on the course website. Remember that spelling of filenames, including case, counts: your file must be named exactly as aboe