Friday 13 December 2019

Python - Day Twenty Nine (December)

WHAT I DID TODAY:

Today I finished all the lessons that I didn't finish last time for the "Introduction to Classes" chapter. It is actually getting much harder to understand, and I guess they are leaving the hardest units last. So far now, I have completed 90% of the course.


90% COMPLETED


This unit mainly consisted, or today mainly consisted of me learning 1-2 new things, but also doing a few different exercises. The exercises were just same codes, but different types of exercises.



  • The first exercise, I created my own class called Triangle, and it inherits from shape. After that I used def and __init__ to 'write' the 3 sides of a triangle. 
EXERCISE #1



  • The second exercise still have the use of the new class code, but this time it's about employees, and payment. From line 10-14, you may see that a 'certain type' of employee gets paid a certain amount of money per hour. I think I've already done lots of similar exercises to this one but this time it's with the use of the class function.
EXERCISE #2



  • The third exercise was a continuation from the very first exercise. I had to add a member variable and a method to the class. The angles had to add up to 180 on all 3 sides together.
EXERCISE #3

EXERCISE #3 SECOND PART / FINAL PART




WHAT I LEARNED:


I learned a few new syntax / functions / codes.



  • This isn't really a new code but I learned something new, more about the 'theory/ explanation' behind inheritance. Code Academy gave me a comparison or an explanation of what inheritance is. Inheritance is basically the process by which one class takes on the attributes and method of another. 


The examples they gave me to understand this concept were:


- A panda is a bear, so a Panda class could inherit from a bear class
- A Toyota is not a Tractor, so it shouldn't inherit from the Tractor class (even if they have lots of attributes in common

INHERITANCE FORMAT





  • The last thing I learned this chapter was the super syntax function. The super function can be used to gain access to inherited methods from a parent or sibling class. I can't say much about this because I didn't do many exercises on this, but so far that's the gist of it.

SUPER SYNTAX FORMAT






WHAT I WILL BE DOING TOMORROW / NEXT TIME:


Next time I will be moving onto a new chapter in this unit, called 'Classes.' Since this was a completely new unit, the next chapter will just be another exercise-type of lesson meaning instead of learning new things, I will potentially have to do exercises with the new codes I learned.


PREVIEW OF NEXT CHAPTER


No comments:

Post a Comment

Adobe Photoshop - Day 10 (June Final Post)

WHAT I DID TODAY / WHAT I LEARNED: For my final project, I thought for a while about what I could do. Then I remembered a while back I saw ...