Must be in Python 3

exercise_2.py
# Define the Student class
class Student():
# Initialize the object properties
def __init__(self, id, name, mark):
# TODO
# Print the object as an string
def __str__(self):
return ' - {}, {}, {}'.format(self.id, self.name, self.mark)
# Check if the mark of the input student is greater than the student object
# The output is either True or False
def is_greater_than(self, another_student):
# TODO
# Sort the student_list
# The output is the sorted list of students
def sort_students(student_list):
# TODO
if __name__== "__main__":
# Read the data
students_file = open('student_list.txt', 'rt')
students_data = students_file.readlines()
student_list = []
for student in students_data:
# Create a student object
fields = student.split(', ')
id = fields[0]
name = fields[1]
mark = fields[2]
student_list.append(Student(id, name, int(mark)))
# Print the original data
print('Original data:')
for student in student_list:
print(student)
# Sort the students
sorted_students = sort_students(student_list)
# Print the sorted data
print('Sorted data:')
for student in sorted_students:
print(student)
student_list.txt
1292467, George Daniel, 89 1398976, Amir Jahani, 76 1392567, Sarah Kylo, 90 1368989, Breanne Lipton, 82 1409916, Robert George, 95 1267756, Jeff Anderson, 84 1367814, Xialing Liu, 86 1458879, Ali Gendi, 77 1407756, Mary Simon, 35 1428867, Georgina Moore, 88 1491228, Brian Johnson, 42 1398875, Samuel Picard, 55
PROGRAM :
class Student:
# Initialize the object properties
def __init__(self, id, name, mark):
self.id = id
self.name = name
self.mark = mark
# Print the object as a string
def __str__(self):
return '- {}, {}, {}'.format(self.id, self.name, self.mark)
# Check if the mark of the input student is greater than the
student object
def is_greater_than(self, another_student):
if(self.mark > another_student.mark):
return True
else:
return False
# Sort the student_list
def sort_students(student_list):
return sorted(student_list, key=lambda student: student.id)
if __name__ == "__main__":
students_file = open('student_list.txt', 'rt')
students_data = students_file.readlines()
student_list = []
for student in students_data:
# Create a student object
fields = student.split(',')
id = fields[0]
name = fields[1]
mark = fields[2]
student_list.append(Student(id, name, int(mark)))
# Print the original data
print("Original data:")
for student in student_list:
print(student)
# Sort the students
sorted_students = sort_students(student_list)
len(sorted_students)
# Print the sorted data
print("Sorted(on id) data:")
for student in sorted_students:
print(student)
OUTPUT :
Original data:
- 1292467, George Daniel, 89
- 1398976, Amir Jahani, 76
- 1392567, Sarah Kylo, 90
- 1368989, Breanne Lipton, 82
- 1409916, Robert George, 95
- 1267756, Jeff Anderson, 84
- 1367814, Xialing Liu, 86
- 1458879, Ali Gendi, 77
- 1407756, Mary Simon, 35
- 1428867, Georgina Moore, 88
- 1491228, Brian Johnson, 42
- 1398875, Samuel Picard, 55
Sorted(on id) data:
- 1267756, Jeff Anderson, 84
- 1292467, George Daniel, 89
- 1367814, Xialing Liu, 86
- 1368989, Breanne Lipton, 82
- 1392567, Sarah Kylo, 90
- 1398875, Samuel Picard, 55
- 1398976, Amir Jahani, 76
- 1407756, Mary Simon, 35
- 1409916, Robert George, 95
- 1428867, Georgina Moore, 88
- 1458879, Ali Gendi, 77
- 1491228, Brian Johnson, 42
SCREENSHOT :
Program:

![if name main : studentsfile open (student list.txt, rt) students_data students_file.readlines () student_list- [] for st](http://img.homeworklib.com/images/f54e7ad2-1577-4c18-ad8b-65f3c626e96c.png?x-oss-process=image/resize,w_560)
OUTPUT :

Must be in Python 3 exercise_2.py # Define the Student class class Student(): # Ini...
IN PYTHON Write the script test3.py that creates and populates a list of OnlineStudent objects. It inputs a requested student, then prints the fields for that student, and also the username of each student in the student's study group. See the pseudocode in Item 3 below. Use the new type of for loop that you can use for reading from a file: # Instead of writing a loop like this fin = open("input-file", "r") line = fin.readline( ) while line...
1. Do the following a. Write a class Student that has the following attributes: - name: String, the student's name ("Last, First" format) - enrollment date (a Date object) The Student class provides a constructor that saves the student's name and enrollment date. Student(String name, Date whenEnrolled) The Student class provides accessors for the name and enrollment date. Make sure the class is immutable. Be careful with that Date field -- remember what to do when sharing mutable instance variables...
A) Please implement a Python script to define a student class with the following attributes (instance attributes): cwid: student’s CWID first_name : student’s first name last_name: student’s last name gender: student’s gender gpa: student’s gpa Please make these attributes as private ones so they have to be accessed via getter/setter methods or property. For this purpose, please define a getter/setter method and property for each of the attributes. Another thing you need to do is to define a constructor that...
The object class should be a Student with the following attributes: id: integer first name: String last name: String write the accessors, mutators, constructor, and toString(). In your main test class you will write your main method and do the following things: Create an array of Student objects with at least 5 students in your array. Write a sort method that must be your original work and included in the main class. The sort method will sort based on student...
I'm trying to sort a list of students from a text file in python(3.7) with three separate sorting functions (Bubble, selection, insert) I'm not sure to why as its not working I'm going to guess its because I'm not using the swap function I built. Every time I run it though I get an error that says the following Traceback (most recent call last): File "C:/Users/tkoto/Desktop/SearchAndSortLab.py", line 146, in <module> main() File "C:/Users/tkoto/Desktop/SearchAndSortLab.py", line 122, in main studentArray.gpaSort() File "C:/Users/tkoto/Desktop/SearchAndSortLab.py",...
PYTHON 3 Object Oriented Programming
***a9q3.py file below***
class GradeItem(object):
# A Grade Item is anything a course uses in a grading scheme,
# like a test or an assignment. It has a score, which is assessed by
# an instructor, and a maximum value, set by the instructor, and a weight,
# which defines how much the item counts towards a final grade.
def __init__(self, weight, scored=None, out_of=None):
"""
Purpose:
Initialize the GradeItem object.
Preconditions:
:param weight: the weight...
Registration Language Java Step 1: Design a class called Student. The Student class should contain the following data: firstName lastName studentID totalCredits gpa Your class should implement the “sets” and “gets” for the class. Include methods: equals, compareTo, toString. Change the toString method (from class) to put each member variable on a new line. Step 2: Write a driver program to test that Student works correctly. Test is with 3 students as given in class. Step 3: Write a “registration”...
Write this code on python 3 only.
Suppose class Student represents information about students in a course. Each student has a name and a list of test scores. The Student class should allow the user to view a student's name, view a test score at a given position, view the highest test score, view the average test score, and obtain a string representation of the student's information. When a Student object is created, the user supplies the student's name and...
Create a Java program that will store 10 student objects in an ArrayList, ArrayList<Student>. A student object consists of the following fields: int rollno String name String address Implement two comparator classes to sort student objects by name and by rollno (roll number). Implement your own selection sort method and place your code in a separate Java source file. Do not use a sort method from the Java collections library.
JAVA program Note: you can't change anything is already written Student.java public class Student { private String name; private String major; private double gpa; public Student(String name, String major, double gpa) { // TO-DO: Assign the given parameters to the data fields. Use the this keyword. } public double getGPA() { // TO-DO: return this.gpa } public String getName() { // TO-DO: return this.name }...