Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Osoba:
- def __init__(self, name, last_name, age):
- self.name = name
- self.last_name = last_name
- self.age = age
- def get_name(self):
- return self.name
- def get_last_name(self):
- return self.last_name
- def get_age(self):
- return self.age
- class Note:
- def __init__(self, grades):
- self.grades = grades
- def get_grades(self):
- return self.grades
- def get_grade(self, subject):
- return self.grades.get(subject, None)
- class Student(Osoba):
- def __init__(self, name, last_name, age, index_nr, grades):
- super().__init__(name, last_name, age)
- self.index_nr = index_nr
- self.notes = Note(grades)
- def get_index_nr(self):
- return self.index_nr
- def get_notes(self):
- return self.notes.get_grades()
- # Przykładowa inicjalizacja dwóch studentów z ocenami z więcej niż trzech przedmiotów
- grades_student1 = {
- "Mathematics": 5,
- "Physics": 4,
- "Chemistry": 3,
- "Biology": 4
- }
- grades_student2 = {
- "Mathematics": 4,
- "Physics": 5,
- "Chemistry": 4,
- "History": 3
- }
- student1 = Student("Anna", "Nowak", 22, "123456", grades_student1)
- student2 = Student("Piotr", "Kowalski", 23, "789012", grades_student2)
- # Wyświetlenie danych studentów
- print(f"Student 1: {student1.get_name()} {student1.get_last_name()}, Age: {student1.get_age()}, Index: {student1.get_index_nr()}")
- print("Grades:", student1.get_notes())
- print(f"Student 2: {student2.get_name()} {student2.get_last_name()}, Age: {student2.get_age()}, Index: {student2.get_index_nr()}")
- print("Grades:", student2.get_notes())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement