In the past two weeks, we've have been looking at programming with Python from a different angle. We were introduced to something called Object Oriented Programming. This (OOP) is a method of programming that is done by creating objects that relate to the real world.
CLASS
Classes are used to create objects and also methods. Classes have this structure:
def NameOfClass:
def __init__(self, a, b, c):
I don't fully understand all the concepts here but from what I've learned every class needs to be initialized with the 'init' method above. Also, the first parameter should always be self; self is used to make reference to the new object that was created. The letters a, b and c above are called attributes. There are also method which are functions created under the class that also relates to the way the class functions in the real world.
We also talked about Stacks. I find this concept very interesting. We can add items to the top of the stack and can only remove the last item that was added. It was a little vague at first until I attended the lab this week. Things got a little clearer and I also had fun brainstorming and I began to really understand how a stack works.
This has really gotten me excited for the next few weeks of class. Programming to me is a little technical but fun and definitely worth it in the end.
In the posts that will be marked by TAs, in order to get better marks, read the text and write a summary of the topic. Also demonstrate the you understand the topic beyond what is written in the text by providing some synthesis of the concepts.
ReplyDelete