1. Learn
  2. /
  3. Courses
  4. /
  5. Intermediate Object-Oriented Programming in Python

Connected

Exercise

Inheriting a Computer class

In this exercise, you'll practice inheritance by creating a class called Tablet. Below is the Computer class, which has been defined for you to use in the following steps.

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

  def install_app(self, app_name, app_store):
    if app_store:
      print(f"Installing {app_name} from App Store.")
    else:
      print(f"Installing {app_name} from other provider.")

  def update_software(self, new_software_version):
      self.software_version = new_software_version

Instructions 1/2

undefined XP
    1
    2
  • Create an instance of the Tablet class called my_tablet, with a software_version of 1.1.1.
  • Use the update_software() method to update the my_tablet's software to version 1.1.2, and print the new value of self.software_version.