class Student:     def __init__(self, id, fn, ln, dob, m='undefined'):         self.id = id         self.firstName = fn         self.lastName = ln         self.dateOfBirth = dob         self.Major = m     def set_id(self, newid): #This is known as setter         self.id = newid     def get_id(self): #This is known as a getter         return self.id     def set_fn(self, newfirstName):         self.fn = newfirstName     def get_fn(self):         return self.fn     def set_ln(self, newlastName):         self.ln = newlastName     def get_ln(self):         return self.ln     def set_dob(self, newdob):         self.dob = newdob     def get_dob(self):         return self.dob     def set_m(self, newMajor):         self.m = newMajor     def get_m(self):         return self.m     def print_student_info(self):         print(f'{self.id} {self.firstName} {self.lastName} {self.dateOfBirth} {self.Major}') all_students = [] id=100 user_input = int(input("How many students: ")) for x in range(user_input):     firstName = input('Enter first name ')     lastName = input('Enter last name ')     dateOfBirth = input('Enter date of birth ')     Major = input('Enter major ')     id = id + 1     if Major == '':         student = Student(id, firstName, lastName, dateOfBirth, Major)     else:         student = Student(id, firstName, lastName, dateOfBirth)     all_students.append(student) for obj in all_students:     obj.print_student_info() search_last_name = input("Enter last name to update major: ") new_major = input("Enter new major: ") found_student = False for obj in all_students:   if obj.get_ln() == search_last_name:     found_student = True     obj.set_major(new_major)     print(f"\nMajor updated for {obj.get_first_name()} {obj.get_last_name()} to {new_major}\n")     break if not found_student:   print("No such student found") print("\nAll students (after major update):") for obj in all_students:   obj.print_student_info() Traceback (most recent call last): File "main.py", line 50, in if obj.get_ln() == search_last_name: File "main.py", line 19, in get_ln return self.ln AttributeError: 'Student' object has no attribute 'ln'

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

class Student:
    def __init__(self, id, fn, ln, dob, m='undefined'):
        self.id = id
        self.firstName = fn
        self.lastName = ln
        self.dateOfBirth = dob
        self.Major = m
    def set_id(self, newid): #This is known as setter
        self.id = newid
    def get_id(self): #This is known as a getter
        return self.id
    def set_fn(self, newfirstName):
        self.fn = newfirstName
    def get_fn(self):
        return self.fn
    def set_ln(self, newlastName):
        self.ln = newlastName
    def get_ln(self):
        return self.ln
    def set_dob(self, newdob):
        self.dob = newdob
    def get_dob(self):
        return self.dob
    def set_m(self, newMajor):
        self.m = newMajor
    def get_m(self):
        return self.m
    def print_student_info(self):
        print(f'{self.id} {self.firstName} {self.lastName} {self.dateOfBirth} {self.Major}')
all_students = []
id=100
user_input = int(input("How many students: "))
for x in range(user_input):
    firstName = input('Enter first name ')
    lastName = input('Enter last name ')
    dateOfBirth = input('Enter date of birth ')
    Major = input('Enter major ')
    id = id + 1
    if Major == '':
        student = Student(id, firstName, lastName, dateOfBirth, Major)
    else:
        student = Student(id, firstName, lastName, dateOfBirth)
    all_students.append(student)
for obj in all_students:
    obj.print_student_info()
search_last_name = input("Enter last name to update major: ")
new_major = input("Enter new major: ")
found_student = False
for obj in all_students:
  if obj.get_ln() == search_last_name:
    found_student = True
    obj.set_major(new_major)
    print(f"\nMajor updated for {obj.get_first_name()} {obj.get_last_name()} to {new_major}\n")
    break
if not found_student:
  print("No such student found")
print("\nAll students (after major update):")
for obj in all_students:
  obj.print_student_info()

Traceback (most recent call last): File "main.py", line 50, in if obj.get_ln() == search_last_name: File "main.py", line 19, in get_ln return self.ln AttributeError: 'Student' object has no attribute 'ln'

Expert Solution
trending now

Trending now

This is a popular solution!

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
  • SEE MORE 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