Question: Using Python: Par 1. You will define Student class with the following attributes: CWID: the students CWID FirstName: the students first name LastName: the students

Using Python:

Par 1.

You will define Student class with the following attributes:

  • CWID: the students CWID
  • FirstName: the students first name
  • LastName: the students last name
  • Gender: the students gender (M or F)
  • BirthDate: the students date of birth (e.g. 03/14/1999)
  • ClassID: the class id that the student took
  • ClassDate: the date when the student took the class (e.g. 01/26/2018)
  • Grade: the students grade for the class

In addition, you will do the following tasks:

  1. Implement a set of setter/getter methods and properties (defined via property() built-in function) which can be used to access the above attributes
  2. Implement a constructor which takes the following string (the format defined in HW assignment #1) as the input parameter:
    1. CWID:3472634, FirstName:John, , Grade:3.7
  3. Implement a method named output which uses str.format() to generate a string according to the following format specification (attributes, and the output ordering and output format of each attribute). The method also returns the generated string.

Attribute

Width

Alignment

1

CWID

12

Center

2

FirstName

15

Left justified

3

LastName

10

Left justified

4

ClassID

9

Center

5

Grade

5

Right justified

Part 2.

Implement Python function according to the following requirements:

  • The function takes an input parameter defining the name of a file in which every record defines data for one student and has the layout defined in above task 2.
  • For each record in the file, the function does the following:
  • Use the record to create a Student object
  • Attach the Student object into a list object
  • For each Student object, the function calls its output method defined in above task 3 to generate the formatted string and then write the string to a file the name of which is passed as the second input parameter of the function.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!