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

Connected

Exercise

Building a class from scratch

In the last exercise of the chapter, you'll step into the role of a Python developer and build your own class from scratch including a constructor!

You'll design a Calculator class, including methods that enable the addition, subtraction, or multiplication of two values.

Instructions

100 XP
  • Define a Calculator class with two parameters on initialization: num_one and num_two.
  • Define an addition() method, which returns self.num_one plus num_two.
  • Define an subtraction() method, which returns self.num_one minus num_two.
  • Define an multiplication() method, which returns self.num_one multiplied by num_two.