DEV Community

Cover image for Python3 Programming - Exercise 20 c - Continuation of OOP concepts
Michael Otu
Michael Otu

Posted on • Updated on

Python3 Programming - Exercise 20 c - Continuation of OOP concepts

Practical

We confidently believe that at this stage, with patience, persistence and clear mind and an intention to solve a problem, you can do so many things, now. Surely some problems will be challenging but through this difficulty, you become better.

Fixed this code. Do not panic, it is easier than you may sweat. Some little assistance.

  • try to understand what every component (method) does.
    • copy the method somewhere and run it or comment some part of it out
    • or just comment the others out and run it
  • run the code multiple times and write down something. Try to trace the execution of the code.
  • break it and see what happens by stabbing it with various input types
    • jot something down - you are becoming a hacker.
    • stabbing means, pass some data to the method or attribute directly. So if there is an input, you provide the input directly.
  • try negative values too - just break it and fix it
  • add comments where you think necessary - try commenting on the code as you may come back in a week or more time.

Download practical file here

Summary

  • Inheritance is an OOP Concept
  • A child class inherits from a parent class
  • pass the parent class as an argument to the child class
  • pass multiple classes that way, for multiple inheritances
  • use super() to access the original attributes and methods of the parent class

Top comments (0)