Operating System Class Hierarchy

Implement a class OperatingSystem and then define child classes for different OS like Windows, Linux, MacOS, each with a unique method features that returns the key features of the respective operating systems.

Example 1:

Input: Windows 

Output: "Windows: User-friendly, heavily GUI-based, and known for its suite of office productivity tools."

Example 2:

Input: Linux 

Output: "Linux: Open-source, highly secure, and customizable with a strong command line interface."

Implement a method features in each of the child classes that returns the respective features of the operating system.

class OperatingSystem:
    def features(self):
        pass

class Windows(OperatingSystem):
    def features(self):
        return "Windows: User-friendly, heavily GUI-based, and known for its suite of office productivity tools."

class Linux(OperatingSystem):
    def features(self):
        return "Linux: Open-source, highly secure, and customizable with a strong command line interface."

class MacOS(OperatingSystem):
    def features(self):
        return "MacOS: User-friendly, seamless integration with Apple products, and known for its robust design tools."

# Test the classes
windows = Windows()
print(windows.features())

linux = Linux()
print(linux.features())

macos = MacOS()
print(macos.features())

© Let’s Data Science

LOGIN

Unlock AI & Data Science treasures. Log in!