首页 > > 详细

Python辅导 Computer Project Specifications 程序辅导 辅导留学生Python设计

Introduction
Class Grade:
str,repr
Class Student:

add_grade,calculate_grade,str,repr,gt,lt,eq
app:
test:
Requirement
CSE 231 Fall 2016
Computer Project #11
(Update 12/4: clarified file prompting for proj11-app.py. Update 12/2: clarified Grade init and
Student str requirements. Update 11/30: clarified specifications of init and str and added a
note about the sample test file).
Assignment Overview
This assignment focuses on the implementation of two Python classes to store grades of students in a
class.
It is worth 55 points (5.5% of course grade) and must be completed no later than 11:59 PM on Tuesday,
December 6.
Assignment Specifications
You will develop “Student” and “Grade” classes and implement all the methods described in the
following section.
You will demonstrate that your implementation of the classes are correct by developing a program
which serves as a test bed for that class.
You will develop an application program which uses those classes to read “students.txt” and “grades.txt”
files and store their data in instances of Student and Grade classes.
Assignment Deliverables
The deliverables for this assignment are the following files:
classes.py – the source code for your Student and Grade classes
proj11-test.py – the source code for your test program
proj11-app.py – the source code for your application program
Be sure to use the specified file names and submit them for grading via the handin system before the
project deadline.
Specifications for Class Grade
1. The constructor (method init) will accept 3 values as parameters, name of the
assignment (string), grade and assignment weight (floats). All three parameters must have
default values—you choose appropriate ones. Also, the attributes cannot be private because you
need to access them in the Student class. That is, do not use double underscores in your names,
i.e. do not use an attribute name such as self.name.
2. The string method (str) and representation method (repr) should return a string
that includes the name, grade and weight of the Grade object in one line.
Specifications for Class Student
1. The constructor (method init) will accept 4 values as parameters, student id (int), first
name (string), last name (string), and a list of all the grade objects for that student. All three
parameters must have default values—you choose appropriate ones, but the appropriate default
value for a list parameter is None, not an empty list ([]).
2. add_grade method should take a Grade object as a parameter and append it to a list of grades
for that student.
3. calculate_grade should multiply all the grade points of the student by their weight and
return the final course grade. (Each Grade object in the list has a value and weight that should be
multiplied together. The sum of all the calculations results the final weighted grade of the student
in the course)
4. The string method (str) and representation method (repr) should return a string
that has the student’s name (with last name first with a comma between the last name and first
name) includes all the grades of the student. This method must call the str method of the
Grade objects. Note that implicitly calling the str method is fine such as str() or
format(), but do not access the individual attributes such as grade.name.
5. gt, lt and eq methods should compare the final grades of two students
together.
Note that you can use calculate_grade method to calculate the final grade of two students.
Never use “==” to check for equality of two float numbers (because floats are approximations
of real numbers). Instead, find the absolute value of the difference of two numbers; if the
difference is less than epsilon (a very small number such as 10**-6), the floats are equal to
each other (that is they are close enough to consider them to be equal). Python has an absolute
value function: abs()
Please note that you may wish to use function “print” to display various items as you are devel⁧†⁩⁥⁴⁣⁥⹬㱬⽶㹯ൣ੡㉴⹩䅮㘠〦╬⁤⁩㕮㕴…†⁥⁥⁲‾⁥⁩㰠†⽬㹥ൡੳ⁴♵㭩♭㬮‼ ☾㭴䜺♣㬠…ⱴ⁵ㅡ㕳╳†⁡†⁥⁦⁥Ⱞ‼㰯 ⽓㹰൥੣⁲㈠㕴╨⁥⁴⁲  ⁙⁥⹲㱯⁡⽭㸠൴੯†⁥⡳䅴⥳㰮⁨⽡㹴ഠ੩⁴⁳㡦㠠⹴ㅨ㝥┼㱢 ⼾㸍ഊੰ㵲㵯㵧㵲㵡㵭㴠㵩㵳㴠㵴㵯㴠㵤㵥㵭㵯㵮㵳㵴㵲㵡㵴㵥㴠㵴㵨㵡㵴㴠㵥㵡㵣㵨㴠㵭㵥㵴㵨㵯㱤⁦⼠㹹൯ੵ䕲⁵㱵†⽡㹮൤ਠ⁵⁲⁲⁳†⁥‼ 㔾ⴍ⁲⁔†⹦㱯⁹⽯㹵൲ਠ䙴⁴†⁥⁤ⱬ⁥†⁰‱⁳…⁡⁢‍㰠⁰⽯㹲൴ਠ⁳‮⁁ⱡ†ⁱ‭㩰㱹⁤⽱㹵൯਻ㄠ⁩㵳††⁲⽴⁩⁴⁡‮⁲‾㰮⽵㹲ഠੴ㑥⁳㵴†⁰⁩⽮⁰⁴‮㱥‬⼠㹡൬੬㜠⁴㵥⁳⁷⁥⼠⁥䕭‼†㰍⁲⽯㹧൲੡⁲ ⁨⁰⁤⁢⁳⁤⁳⁰⁲Ɽ††㱨⁲⽥㹡൤੥⁵⁥⁲‾⹲㱰⁥⼠㹡൮੤ㅲ㩥⁳⁴⁳Ⱶ⁴䤠⁥⽨㱥⁆⽯㹲ഠ੥㉡㩭⁰⁨‾⁤Ⱨ†䥬⁴†⽵㱳⁡⽴㹩൮੧㍆㩲⁥⁡⁦Ɫ⁲䤠 ⁲⽥㱴⽳㸠൦੯㐠㩴⁨䍥⁲‾‱⁵Ɽ⁥Ɒ⁴ⱡ䤠⁷⁵䥳⁥⁴⁣⁥㱴⁳⽯㹬൶੥†⹭㰠⁳⽣㹲൩੢ ⁲⁥⁲⁣⁲⁰⁡⁷Ɱ⁴⁴†㱭†⼦㹬൤ੱ‱⠱⁰⁰⁤†⁨‾⁦⥯⹲㱴⽤㹱൵੯⌻⁣㰦ⁱ⽵㹯഻ਮ⌼⁢ㄠ㨯‾㔍㰊†⽔㹨൥ਠ⍰⁲㉧㩲⁡㍭㰠⽬㸠ൡੴ⍴⁥㍰㩴†㑴㱯⁣⽣㹥൳ੳ⌠⁴㑥㨠⁦㙩㱬⽥㸠named “students.txt” and “grades.txt”. If any of the
input files cannot be opened, the program will display an appropriate message and halt. (Since the first
posted version of this document didn’t specify that the program must prompt for these two file names,
you have the option of prompting for them or not. However, if you prompt for them, our test program
will provide the name grades.txt to the first prompt and students.txt to the second prompt.)
3. The grades.txt file will contain three or more lines. The first line contains the weight of each
assignment, the second line contains the labels and the name of the assignments. Line 3 and subsequent
lines contain grade information for a student. Each line has a student id and all the grades of a student.
The information of each assignment should be stored in an instance of “Grade” class. A list of Grade
objects should be passed to the constructor of “Student” class.
4. The students.txt file will contain one or more lines, where each line contains the information of a
student. Each line has an id, first name and last name. That information should be stored in an instance
of “Student” class along with the list of “Grade” objects explained above.
5. The application should store all “Student” objects in a list and should print them ( print(student) ) like
the sample output provided below.
6. The application should print the class average at the end.
Assignment Notes
1. You would be wise to develop your implementation of “Student” and “Grade” classes and your test
program incrementally and in parallel. That is, implement one class method at a time and then test that
method by adding statements to your test program.
Clearly, the first class method which must be implemented and tested is the constructor (init).
Perhaps the second class method to implement and test is str__ so that you have a way to display
the value of an object of type “Student” and “Grade” using function “print”.
After implementing and testing those methods, you would continue to implement and test one method at
a time until you have completed the class.
Be sure to insert and

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!