elif choice == '2': # Remove student student_id = input("Enter Student ID to remove: ") manager.remove_student(student_id)
elif choice == '8': # Exit save = input("Save data before exiting? (y/n): ").lower() if save == 'y': manager.save_to_file() print("\nGoodbye! 👋") break
if == " main ": main()
def find_student(self, student_id): """Find a student by ID""" return self.students.get(student_id)
elif choice == '6': # Save data manager.save_to_file()
NetBeans supports a solid Python debugger. You can set breakpoints by clicking in the left margin of the editor and clicking the button (or Ctrl+F5 ). You can then step through code, inspect variables, and watch expressions just like you would with Java.
def save_to_file(self, filename='students.json'): """Save student data to JSON file""" data = [student.to_dict() for student in self.students.values()] with open(filename, 'w') as f: json.dump(data, f, indent=2) print(f"✓ Data saved to filename")
def get_all_students(self): """Return all students sorted by name""" return sorted(self.students.values(), key=lambda s: s.name)
else: print("Invalid choice! Please enter 1-8.")
This example demonstrates: