BaşlayınÜcretsiz Başlayın

Using inheritance to create a class

You've previously written a Document class for text analysis, but your NLP project will now have a focus on Social Media data. Your general Document class might be useful later so it's best not to destroy it while your focus shifts to tweets.

Instead of copy-pasting the already written functionality, you will use the principles of 'DRY' and inheritance to quickly create your new SocialMedia class.

Bu egzersiz

Software Engineering Principles in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Document has been preloaded in the session.
  • Complete the class statement to create a SocialMedia class that inherits from Document.
  • Define SocialMedia's __init__() method that initializes a Document.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Define a SocialMedia class that is a child of the `Document class`
class ____:
    def __init__(self, text):
        ____.____(self, text)
Kodu Düzenle ve Çalıştır