My quiz point : 0
10-2. 클래스 상속
10-2-1. 클래스의 상속에 대한 이해를 돕기 위한 예입니다. 프로그램을 완성해 보세요.(10 point)
★ 노란색 버튼을 클릭해 보세요!
▒ 프로그램 실행 결과
홍길동
이름은 홍길동이고 나이는 20살 입니다.
▒ 프로그램 코드
class Person :
    def __init__(self, name) :
        self.name = name

    def show_name(self) :
        print(self.name)
        
    def show_age(self) :
        print(self.age)

class Student(Person) :
    def __init__(self, name, age) :
        super().__init__(name)
        self.age = age

    def introduction(self) :
        print("이름은 %s이고 나이는 %d살 입니다." % (self.name, self.age))    

x = Student("홍길동", 20)
x.show_name()
x.introduction()
    
★ 박스 안 코드 입력 후 Enter 키를 눌러 보세요!
▒ 프로그램 실행 결과
홍길동
이름은 홍길동이고 나이는 20살 입니다.
▒ 프로그램 코드
class Person :
    def __init__(self, name) :
        self.name = name

    def show_name(self) :
        print(self.name)
        
    def show_age(self) :
        print(self.age)

class Student(Person) :
    def __init__(self, name, age) :
        super().__init__(name)
        self.age = age

    def introduction(self) :
        print("이름은 %s이고 나이는 %d살 입니다." % (self.name, self.age))    

x = Student("홍길동", 20)
x.show_name()
x.introduction()