1 class Course: 2 B 4 5 7 B B 6 7 8 9 definit__(self): self.roster = [] 2 1 2 B 4 class Student: 5 def add student (self, student): self.roster.append(student) 4 5 6 def drop_student (self, last_name): for i, student in enumerate(self.roster): if student.get_last() == last_name: del self.roster[i] break definit__(self, first, last, gpa): self.first = first self.last last self.gpagpa 2 1 2 3 def main(): def get_last (self): return self.last course Course() henry Student ("Henry", "Nguyen", 3.5) brenda = Student ("Brenda", "Stern", 2.0) lynda Student ("Lynda", "Robison", 3.2) sonya = Student ("Sonya", "King", 3.9) = 8 9 course.add_student (henry) 2 course.add_student (brenda) 1 course.add_student (lynda) 2 course.add_student (sonya) B print("Course size:", len(course.roster), "students") 4 course.drop_student("Stern") 5 print("Course size after drop: ", len(course.roster), "students") 6 7 if __name__ 8 main() 11 == __main__":
1 class Course: 2 B 4 5 7 B B 6 7 8 9 definit__(self): self.roster = [] 2 1 2 B 4 class Student: 5 def add student (self, student): self.roster.append(student) 4 5 6 def drop_student (self, last_name): for i, student in enumerate(self.roster): if student.get_last() == last_name: del self.roster[i] break definit__(self, first, last, gpa): self.first = first self.last last self.gpagpa 2 1 2 3 def main(): def get_last (self): return self.last course Course() henry Student ("Henry", "Nguyen", 3.5) brenda = Student ("Brenda", "Stern", 2.0) lynda Student ("Lynda", "Robison", 3.2) sonya = Student ("Sonya", "King", 3.9) = 8 9 course.add_student (henry) 2 course.add_student (brenda) 1 course.add_student (lynda) 2 course.add_student (sonya) B print("Course size:", len(course.roster), "students") 4 course.drop_student("Stern") 5 print("Course size after drop: ", len(course.roster), "students") 6 7 if __name__ 8 main() 11 == __main__":
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Code did not work
Expert Solution
Introduction:
-
Class Student defines a Student object, which has the properties first, last, and gpa.
- Class Course defines a Course object, which contains a list of Student objects (roster).
The drop_student() method loops through the roster and deletes the student with the matching last name.
Step by step
Solved in 4 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education