[SOLVED] Practicing an implementation of class and objects. File access is also implemented.
Can you help me understand this Python question?
Practicing an implementation of class and objects. File access is also implemented.
Refer to the slides posted on Blackboard. For better understanding on video lecture, please check out the video lecture from http://cysecure.org/505/online19f/index.html > Bluebox.
1) Define a class called Section
2) Declare variables of the class: student in dictionary, instructor in String, title in String. For these static variables, create a function __init__(), which can assign each value to a corresponding class variable.
3) Define the functions:
a) grading(pts): taking pts in number and returns a letter grade. Refer to the syllabus of this course.
b) posting(student, pts): update the student dictionary with the value list of points and letter grade. In this case, letter grade should be obtained from the method grading().
c) updating(student, pts): Consider a situation where the points earned by a student need to be update. That particular student’s points is updated and therefore the letter grade too.
4) At each step above, please display the states of variables.
For example, it runs as follows:
>>> (executing lines 1 to 64 of “classSection.py”)
Python is taught by John
B
A
B
C
{‘Adam’: [81, ‘B’], ‘Sam’: [99, ‘A’], ‘Peter’: [82, ‘B’], ‘Chris’: [72, ‘C’]}
Enter any update request (name points): Chris 81
{‘Adam’: [81, ‘B’], ‘Sam’: [99, ‘A’], ‘Peter’: [82, ‘B’], ‘Chris’: [81, ‘B’]}
Note that the second dictionary shows that Chris’ grade was updated.
Another sample run:
>>> (executing lines 1 to 64 of “classSection.py”)
Python is taught by John
B+
B
C+
C
{‘Adam’: [88, ‘B+’], ‘Sam’: [85, ‘B’], ‘Peter’: [77, ‘C+’], ‘Chris’: [72, ‘C’]}
Enter any update request (name points): jdkf 90
{‘Adam’: [88, ‘B+’], ‘Sam’: [85, ‘B’], ‘Peter’: [77, ‘C+’], ‘Chris’: [72, ‘C’], ‘jdkf’: [90, ‘B+’]}
Note that since the student name is new, it was added. If not realistic, you may improve it. Is that case, please express in your submission how you improved. Depending on improvement, a bonus point will be given.
SUBMIT:
1) Your source coding file. The file shows each every statement as shown the steps above, so the execution of the file shows the all print statements.
2) Screenshot(s) that may show the integrity of your work