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
- # Przykładowe utworzenie obiektu klasy Osoba
- osoba = Osoba("Jan", "Kowalski", 30)
- print(osoba.get_name()) # Output: Jan
- print(osoba.get_last_name()) # Output: Kowalski
- print(osoba.get_age()) # Output: 30
- class Student(Osoba):
- def __init__(self, name, last_name, age, index_nr):
- super().__init__(name, last_name, age)
- self.index_nr = index_nr
- def get_index_nr(self):
- return self.index_nr
- # Przykładowe utworzenie obiektu klasy Student
- student = Student("Anna", "Nowak", 22, "123456")
- print(student.get_name()) # Output: Anna
- print(student.get_last_name()) # Output: Nowak
- print(student.get_age()) # Output: 22
- print(student.get_index_nr()) # Output: 123456
Add Comment
Please, Sign In to add comment