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. 

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