Tuesday 10 February 2015

Using binary code and simple python commands

What is Binary code?

Binary code is the language that computers are coded in. Like humans count in units, tens, thousands and so on, in multiples of 10, binary code is written multiples of 2. The numbers we use are 1, 2, 4, 8, 16 and so on doubling the previous number. We represent theses numbers as 0s and 1s. 

We use 1s and 0s because in the circuitry of a computer, there are switces, the one means that the computer turns on that switch and the 0 mean it is off. 
As we can see in the picture, it shows the column as well as some of the simple numbers.
Some other examples are:
00011= 3
10001= 17
It is important that we understand binary, as we can only fully use the full potential of computers if we can use binary, because computers are coded in binary.

Python

In python, we use various symbols for every day signs like divide multiply, add, subtract.
we use / for an accurate divide, and // if we just want the whole number.
We can also use % to get the remainder of a certain calculation. for example:
19/5= 3.8
19//5=3
19%5=4
because when you divide 19 by 5, 5 goes into it exactly 3 times, and then there is 4 left over( the remainder)
For multiply we use *, for addition we use+ and for subtraction we use -.

Fibonacci sequences

In nature, a very common pattern is the fibonacci sequence, where you add the 2 previous terms to get the next term. so it starts with 1, 1, 2, 3, 5, 8, 13, 21 and so on. 
Here are some intresting examples:

No comments:

Post a Comment