Friday 20 December 2019

Python - Day Thirty One (December)

WHAT I DID TODAY:


Today I didn't finish just the files input/output unit but I finished the whole entire Python 2 course. Even though this was the very last chapter, it wasn't a review, but it was actually a completely new unit where I learned tons of new syntax and codes. 


100% COMPLETE
LESSONS I DID TODAY


     FINAL EXERCISE


The final review of course consisted of all the new codes I learned, it may look confusing but all this does is opens a new 'text file' kind of and reads it. If the text.txt tab has written 'My Data' it will return as true as stated in the code.


WHAT I LEARNED:



This unit was mainly about how to read/write information from a different file on your computer. Code Academy mentions that all we have been doing is typing codes, and the results come out in the output console. I learned that this process is called file I/O which stands for input/output. And Python already has built-in functions for this.


  • The first thing I learned was the open() function. I'm sure the name sounds pretty self-explanatory but basically, this code tells Python to open output.txt in"w" mode which stands for "write." Doing this opens the file in write mode.
open() code


  • The second thing I learned was the reading file code. This code just reads the output.txt.
.read() code

  • The third thing I learned was a bit confusing, but I'm pretty sure it opens and closes files for you, as Python usually does all the work. File objects contain a special pair of built-in methods.
with and as syntax


WHAT I WILL BE DOING NEXT TIME:

So now that I have finished the entire course, I was thinking of doing a final game such as creating a small program or even game to finish off.

I will be taking steps and start thinking about what to do and then start on it next time.



Wednesday 18 December 2019

Python - Day Thirty (December)

WHAT I DID TODAY / LEARNED:

Today I did the chapter called, 'Classes.' This chapter was mainly just a review for me to practice my skills, while doing a single exercise, so I didn't learn anything new. I'm now done 95% of the entire Python course.


95% COMPLETE


The main thing I had to do this lesson was working on a single exercise with multiple steps spanning out. Then at the end, there was a review where I had to start from scratch and it was just a total different exercise.

I will explain the couple main/important steps of the exercise..


  • The first step is actually 4 steps combined. I just combined it together into one explanation because it would take too long to just talk about one each at a time, and also it can make more sense and be more informative in this type of format. In this 'first step' I created a new class called car, then added the condition it's in using variables, then printed it.
STEP 1


  • The second step was using the car's type of class to create new things/variables such as the model of the car, color, etc; After that I just printed out the results.
STEP 2


  • The third step is the very final step with everything combined. I already explained mostly what was going on above, and since the same type of things was added below, I don't think it's necessary to go through another explanation. But basically the final picture, there were just a few new factors that were added to the 'car class' using variables such as battery.
STEP 3



  • The very final exercise I had to do was a different exercise, using the same types of codes. In this exercise, I created a class called Point3D that inherited from the object variable. Then I assigned the x,y,z to member variables. This makes Python represent the objects in the following format. (x,y,z)
FINAL REVIEW



WHAT I WILL BE DOING TOMORROW / NEXT TIME:


Next time I will be doing the very last unit/chapter of the Python course. This is the final 5% of the course.

PREVIEW OF NEXT LESSON

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


Wednesday 11 December 2019

Python - Day Twenty Eight (December)

WHAT I DID TODAY:

Today I worked on the new unit called, "Introduction to Classes." There were 18 lessons today and I did 9 of them. So far I learned about a new function or code. It's called 'classes.' 


COMPLETED


Within the 9 lessons, I obviously did exercises after learning the new function. It was a bit different this time because each lesson was like a new step to the same exercise. I don't know if that makes sense but basically it was just the same exercise that I worked on, while adding new things/codes I learned.


  • The first step was to just set the base of the exercise. The code below does not do anything and is just the start.
STEP 1

  • The second step was to get the code started. I added some 'meaning' to the function below by adding in def. Since there's also new and unfamiliar codes in this exercise, I will be explaining them below in the next section.
STEP 2

  • This step is to 'give the object' a name. The 'name' refers to the created object's name by typing self.name = name .. 
STEP 3


  • This final step was to add a method, description, and animal class. I had to use two different print statements, to print out the name and age of an animal.
STEP 4

(THERE WAS LITTLE STEPS BEFORE STEP 4 BUT I THOUGHT IT WAS UNNECESSARY SO I SHOWED STEP 4 AS THE NEXT STEP)




WHAT I LEARNED:


Today I learned about the class function, which is the main topic of the whole unit as said in the title.


  • The first thing I learned was of course the actual class function itself. It consists of the class keyword, the name of the class, and the class from which the new class inherits in parentheses. The format goes like this 'class NewClass(object) : What this does is basically just gives power and abilities of a Python object. (User-defined Python class names start with a capital letter.)
CLASS FORMAT EXAMPLE


  • The second thing I learned was the __init__() function. This function is mandatory and very much required for classes, as it utilizes the objects it creates. It's basically considered as the function as a thing that 'boots up' each object the class creates.
__INIT__ EXAMPLE


(KEEP IN MIND THAT I AM USING THE SAME IMAGE FROM ABOVE FOR __INIT__ BECAUSE THIS WAS BASICALLY THE ONLY TIME AND PHOTO THAT WAS PRESENT)




WHAT I WILL BE DOING TOMORROW / NEXT TIME:


Next time I will finish up the outstanding lessons that I didn't get to finish today.

NEXT LESSONS



Tuesday 10 December 2019

Python - Day Twenty Seven (December)

WHAT I DID TODAY:


Today I finished all the remaining lessons I couldn't complete last class in 'Introduction to Bitwise Operators.' There were 7 lessons left that were fairly difficult, but wasn't as hard as the first half because the first half was where I had to completely learn something new and understand how the 'base' of the unit works.

THE LESSONS I COMPLETED TODAY

I have now gone up to 85% of the overall course.

85% COMPLETED



The few important exercises I did were...

  • The first exercise was pretty random, and I still kind of don't understand the purpose of this exercise, except for it just basically incorporating the new things I learned today and last class. But I think all this exercise does is to check if th 'bit' is on or not. 
EXERCISE #1


  • The second exercise was actually just a review. It was a super short review of everything I learned. All this review was that the function flip_bit taking in a number, flipping it, and storing it in as a result.
EXERCISE #2




WHAT I LEARNED:


I learned a lot of different codes/functions that works with the bitwise operators / binary numbers.



  • The first thing I learned was the & bitwise operator. The & bitwise operator compares two numbers, and returns a number where the bits of that number are turned on if the corresponding bits of both numbers are 1. This was somewhat the definition of it. I'm still trying to understand this one more because I'm still a bit iffy at some parts.
EXERCISE #1 USING &


  • The second thing I learned was the | bitwise operator. This is the OR that compares two numbers and returns a number where the bits of that number are turned on. 
EXERCISE #2 USING |


  • The third thing I learned was the ^ operator. Or also named XOR compares two numbers and returns a number where the bits of that number are turned on.
EXERCISE #3 USING ^


  • The fourth thing I learned was the ~ operator. This one was very simple as you can see. It was the only one that I truly understood. Using it prints out a number but turns it into an opposite sign. 
EXERCISE #4 USING ~



I did not talk much about these because the exercises I had to do with these were very short. I didn't have a chance to learn more about it. But maybe there isn't much to it and it's just that like it says. 



WHAT I WILL BE DOING TOMORROW / NEXT TIME:


Next time I will be moving onto the next unit. It is called, "Introduction to Classes." I'm pretty sure there are like 18 lessons or something like that, so as always I will probably split it again.

DESCRIPTION OF NEXT UNIT




Wednesday 4 December 2019

Python - Day Twenty Six (December)

WHAT I DID TODAY:


Today I started on the 'introduction to bitwise operators' unit. All computer's numbers are represented by bits. Bitwise operators aren't super important to learn, but they do pop up from time to time, says Code Academy. I only got through 6 lessons this time because this was really tricky and confusing for me at first to understand how it all worked. 


THE LESSONS I WENT THROUGH


I'm still a bit iffy on giving a proper explanation, but I found a video that helped me explain what I will be showing below later.


Since I only went through 6 lessons, I didn't do much today, rather I was just trying to mainly understand the process. But I did get to do a few exercises based on the new things I learned.




  • The first exercise may look SUPER FOREIGN right now, but once I actually understood what I was doing it got easier. In the first exercise I was told to write the 'binary' version of every number. I had to start writing from line 4-13.

CONVERT TO BINARY NUMBERS EXERCISE



  • In the second exercise, I only had to print one thing on line 7. It was the use of int() I will explain more on this in the 'WHAT I LEARNED' section. But basically all this exercise was, was to print out the equivalent number of the binary one.
INT() EXERCISE




WHAT I LEARNED:


It was probably a bit hard following those exercises above because they may look very new and confusing, but hopefully after this section it becomes a bit more familiar.

The things I learned will mainly be from the exercises above.


  • The first thing I learned was binary numbers, which probably makes up this whole unit. This part was the hardest part for me because it was really tricky, but I eventually understood it after watching a video. When writing binary numbers, the format goes like this, 0b#. So you have to write 0b and then the binary number that is equivalent to the actual number you want.
BINARY NUMBERS FORMAT

Binary numbers come from the power. (^) When writing binary numbers for me, I had to break it down, and use numbers from the power of 2 list. (I listed them)

I know from myself that reading an explanation to this is confusing, so I will also provide a video that explains what I just said better, and that helped me actually understand it.





Also to add onto this, I was also shown a new code that just gives you the binary number of a regular number. (so you don't have to actually figure it out yourself) but it's also important to know where it came from and how it actually works.

The new code I learned was bin() You just insert the number you want inside the bracket and it prints out the binary number.

BIN() CODE



  • The second thing I learned was int() I'm pretty sure this code has already made an appearance before, but code academy showed me another way to use it. Turns out there is a second parameter that you can use along with this code.

INT() CODE

When given a string containing a number and the base that number is in, the function will return the value of the number converted to base 10. I can't say much more about this because this is pretty much how much of it I worked with.



WHAT I WILL BE DOING TOMORROW / NEXT TIME:


Next time I aim to complete all of the remaining lessons. I think it will be possible because I went through the main tricky obstacle.

REMAINING LESSONS

There is 7-8 lessons left, but I will finish it no matter what because I don't want to drag this onto 3 days. 

Monday 2 December 2019

Python - Day Twenty Five (December)

WHAT I DID TODAY:



Today I finished the remaining 9 lessons in the 'Advanced Topics in Python' unit that I couldn't finish last class. Just like last class, I was still working on the same topics as you may have guessed. But to review/sum it up again, I worked on dictionaries/lists, list slicing, and working with numbers.  That's what I did last class but also this class with different exercises.


I have completed 80% of the overall course now.


80% COMPLETED



I did a few simple exercises, and also a few reviews based on the topics mentioned above.



  • The first exercise just required me to count the numbers backwards by 10 starting from 100 or technically to be exact 101. This one was the easiest as it was very self-explanatory and only used 1-2 variables along with list slicing on line 4.
EXERCISE #1 COUNTING BACKWARDS BY 10


  • The second exercise, I had to use list slicing to make Python print only the numbers of 3 and 5. I feel like I already posted lots of similar exercises to this one but since it's something I did today, I'll post it again.
EXERCISE #2 COUNTING BY 3'S AND 5'S


  • The third exercise was 'decoding a secret message.' Basically, there was a hidden message that was backwards and only every second letter counted. Instead of an actual person having to decipher it, you can use coding to make the computer decipher it for you instead.
EXERCISE #3 SECRET MESSAGE


  • The final review I had to do will show an unfamiliar code that I will be explaining in the next section below. But this last review was a really short one that included variables, list slicing, and the new code. In this final review, I had to decipher a secret message once again, except this time I had to also use the new code/function.
FINAL REVIEW

( The code/function that may be unfamiliar is line 3. )




WHAT I LEARNED:


Today I only learned one new thing, but it's normal to not learn so many new things nowadays because I'm at a certain point where this Python course went through a lot already. 



  • The new function I learned was filter(lambda) This one slightly confuses me a bit, but I eventually started understanding it a bit more. This certain code is actually related to 'functional programming,' which means you're able to pass functions around just like variables/values. The function the lambda creates is an anonymous function.
EXAMPLE USE OF THE NEW FUNCTION

And the filter determines what to filter out from the 'lambda.' Lambda could potentially be the exact same as using the def function. 



WHAT I WILL BE DOING TOMORROW / NEXT TIME:


Next time I will move onto a new unit named,'Introduction to BitWise Operators.' Considering the title, I'm pretty sure I will be learning at least one new thing if not a bunch.

DESCRIPTION OF NEXT UNIT

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 ...