In [1]:
from notebook.services.config import ConfigManager
from IPython.paths import locate_profile
cm = ConfigManager(profile_dir=locate_profile(get_ipython().profile))
cm.update('livereveal', {
'theme': 'solarized',
'transition': 'zoom',
'start_slideshow_at': 'selected',
})
Out[1]:
a % b
The remainder after a
is divided by b
In [27]:
13 % 5 == 3
12 ** 2 == 144
146 % 67 == 12
19 % 8.5 == 2
4 ** (3 % 11)
Out[27]:
A single digit of binary is 0
or 1
. In a computer, this takes up 1 bit
of memory.
8 bits
= 1 byte
1 byte
is the smallest addressable unit of memory
Because 8 bits
is 1 byte
, then all units beyond that are multipls of 8.
1024 byte
= 1 kilobyte
1024 kilobytes
= 1 ??
In [ ]:
1024 `megabytes` = 1 `??`
In [ ]:
1024 `gigabyte` = 1 `??`
In [ ]:
1024 `terabyte` = 1 `??`
1024 byte
= 1 kilobyte
1024 kilobytes
= 1 megabyte
1024 megabytes
= 1 gigabyte
1024 gigabytes
= 1 terabyte
1024 terabytes
= 1 petabyte
1024 petabytes
= 1 exabyte
1024 exabytes
= 1 zettabyte
1024 zettabytes
= 1 yotabyte
So, what about these hard drive manufacturers here? They are not alone, many follow this standard!
So, when you buy a laptop and they say it has a 3000GB hard drive (or 3TB), this may not be the case!
How fast is your internet? Speed test it now or test the 4G on your phone.
How many mega bytes per second?
In [26]:
movies_per_gb = 1024.0/650.0
print(movies_per_gb) #number of videos I can store in 1GB
movies_per_tb = float(movies_per_gb * 1024)
print(movies_per_tb)
print(movies_per_tb * 3) #movies I can fit on my 3TB drive
print(((1024.0/650.0) * 1024.0) * 3.0)
In [ ]:
32 16 8 4 2 1
--------------
0 0 0 1 0 1
Using the method in the slide above, we can convert by doing the following things:
In [28]:
Yes.
16 8 4 2 1
--------------
1
Move to next bit. NUMBER = 27 - 16 = 11
Does 8 go into 11?
In [ ]:
Yes.
16 8 4 2 1
--------------
1 1
Move to next bit. NUMBER = 9 - 8 = 1
Does 3 go into 4?
In [ ]:
No.
16 8 4 2 1
--------------
1 1 0
Move to next bit. NUMBER still equals 1
Does 3 go into 2?
In [ ]:
Yes.
16 8 4 2 1
--------------
1 1 0 1
Move to next bit. NUMBER still equals 1
Does 1 go into 1?
In [ ]:
Yes.
16 8 4 2 1
--------------
1 1 0 1 1
Move to next bit. NUMBER = 1 - 1 = 0.
We are at the right most bit.
So, the binary representation for 27 is:
11011
In [ ]:
128 64 32 16 8 4 2 1
---------------------------
0 1 1 1 1 1 1 1 (127)
0 0 0 0 0 0 1 0 (2)
0 1 0 0 0 0 0 0 (64)
0 1 0 0 1 1 1 1 (79)
0 1 1 0 0 0 1 0 (34)
---
128 64 32 16 8 4 2 1
---------------------------
1 1 1 0 1 1 1 1 (239)
0 0 0 1 1 1 1 0 (30)
1 1 1 1 0 0 0 1 (241)
1 0 1 0 1 0 1 0 (170)
0 1 0 1 0 1 0 1 (85)
Ever played Kakuro or Sudoku? Well, Bakoru is a modification thought up by the people behind Computing At School. The aim is to fill in the blanks so they amount to the row and/or column total.
A grid (of any size) where numbers on each row must add up to the total at the stop
blocks (rows with a total written in them and marked by a diagonal separator.
Columns must also add up to the total in the stop
block. A stop block would typically look like this:
Let's try to play Kakuro first.
Why can we not just give a number to every letter in the alphabet?
How would we represent upper case? How would we handle symbols? What about other alphabets?
_ ____ ____ ___ ___ _
/ \ / ___| / ___|_ _|_ _| |
/ _ \ \___ \| | | | | || |
/ ___ \ ___) | |___ | | | ||_|
/_/ \_\____/ \____|___|___(_)
The American Standard Code for Information Exchange. All characters are stored as codes and can be found through a lookup table.
NOTE: Character encoding is covered the Software Development Skills 2 course in the next semester.
Convert the following binary values to decimal. Then use the look up table to find the char values and create words. Rearrange to form a sentence:
01100111 01101001 01110110 01100101
01101110 01100101 01110110 01100101 01110010
01110101 01110000
01100111 01101111 01101110 01101110 01100001
01111001 01101111 01110101