1. Learn
  2. /
  3. Courses
  4. /
  5. Python 중급 객체 지향 프로그래밍

Connected

Exercise

다중 상속

이 연습 문제에서는 Smartphone이라는 새 클래스를 만들어 다중 상속을 구현해 볼 거예요.

아래에는 Smartphone 클래스를 만들 때 사용될 Computer와 Telephone 클래스 정의가 있어요. 두 클래스를 모두 꼼꼼히 살펴보세요!

class Computer:
  def __init__(self, brand):
    self.brand = brand

  def browse_internet(self):
    print(f"Using {self.brand}'s default internet browser.")
class Telephone:
  def __init__(self, phone_number):
    self.phone_number = phone_number

  def make_call(self, recipient):
    print(f"Calling {recipient} from {self.phone_number}")

Instructions 1/3

undefined XP
    1
    2
    3
  • Computer와 Telephone을 상속받는 Smartphone 클래스를 만들고, brand, phone_number, music_app 매개변수를 받게 하세요.
  • Smartphone의 부모 클래스 생성자를 호출하고, 인스턴스 속성 music_app을 정의하세요.