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
icon
Related questions
Question

Code did not work

1:Compare output
Your output
2:Unit test ^
Tests course.drop_student('Sally') drops Sally from the course
AttributeError: 'Course' object has no attribute 'count_students'
3:Unit test ^
Course size: 4 students
Course size after drop: 3 students
4:Unit test
Tests course.drop_student('Sally') and course.drop_student('Tyson') drops Sally and Tyson from the course
AttributeError: 'Course' object has no attribute 'count_students'
Tests course.drop_student('Fish') drops no students from the course
AttributeError: 'Course' object has no attribute 'count_students'
3/3
0/2
0/2
0/3
Transcribed Image Text:1:Compare output Your output 2:Unit test ^ Tests course.drop_student('Sally') drops Sally from the course AttributeError: 'Course' object has no attribute 'count_students' 3:Unit test ^ Course size: 4 students Course size after drop: 3 students 4:Unit test Tests course.drop_student('Sally') and course.drop_student('Tyson') drops Sally and Tyson from the course AttributeError: 'Course' object has no attribute 'count_students' Tests course.drop_student('Fish') drops no students from the course AttributeError: 'Course' object has no attribute 'count_students' 3/3 0/2 0/2 0/3
1 class Course:
2
definit__(self):
self.roster
3
4
5
6
7
8
9
0
1
2
3
4 class Student:
5
6
7
8
9
0
1
2
3 def main():
4
5
6
7
Student ("Brenda", "Stern", 2.0)
lynda Student ("Lynda", "Robison", 3.2)
Student ("Sonya", "King", 3.9)
8
sonya
9
0
course.add_student (henry)
course.add_student(brenda)
course.add_student (lynda)
1
2 course.add_student (sonya)
3 print("Course size:", len(course.roster), "students")
4
5
6
7 if __name__ ==
8
main()
def add_student(self, student):
self.roster.append(student)
def drop_student (self, last_name):
for i, student in enumerate(self.roster):
if student.get_last()
del self.roster[i]
break
definit__(self, first, last, gpa):
self.first = first
self.last = last
self.gpagpa
def get_last (self):
return self.last
=
course = Course()
henry Student ("Henry", "Nguyen", 3.5)
brenda
last_name:
11
course.drop_student("Stern")
print("Course size after drop: ", len(course.roster), "students")
_main__":
Transcribed Image Text:1 class Course: 2 definit__(self): self.roster 3 4 5 6 7 8 9 0 1 2 3 4 class Student: 5 6 7 8 9 0 1 2 3 def main(): 4 5 6 7 Student ("Brenda", "Stern", 2.0) lynda Student ("Lynda", "Robison", 3.2) Student ("Sonya", "King", 3.9) 8 sonya 9 0 course.add_student (henry) course.add_student(brenda) course.add_student (lynda) 1 2 course.add_student (sonya) 3 print("Course size:", len(course.roster), "students") 4 5 6 7 if __name__ == 8 main() def add_student(self, student): self.roster.append(student) def drop_student (self, last_name): for i, student in enumerate(self.roster): if student.get_last() del self.roster[i] break definit__(self, first, last, gpa): self.first = first self.last = last self.gpagpa def get_last (self): return self.last = course = Course() henry Student ("Henry", "Nguyen", 3.5) brenda last_name: 11 course.drop_student("Stern") print("Course size after drop: ", len(course.roster), "students") _main__":
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.
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Unreferenced Objects
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.
Similar questions
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education