<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Math, Representation and Binary Arithmetic
Dr. Chris Gwilliams
gwilliamsc@cardiff.ac.uk
Contents
Mathematic Operations
Binary Conversion
Boolean Logic
Binary Arithmetic
Operations
We have covered (+, -, / and *), but there are more built in.
**
Step1:  Binary
A way of representing data using an ON or OFF flag using a 1 or a 0.
Why does it exist?
Because it the simplest method of storing information. A trivial yes or no can be stored, as well as whole novels (or programs, as you will be writing)
How, you ask?
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 ??
Step2:  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!
Exercise
How fast is your internet? Speed test it now or test the 4G on your phone.
How many mega bytes per second?
MB vs Mb
1 Megabit (Mb) is NOT equal to 1 Megabyte (MB)!
1 megabit = 1,000,000bits = 1/8 of a megabyte
Exercise
If I have a 3TB hard drive, how many 650 MB video files can I store on it?
Step3:  Binary
Everything we store (movies, text, programs), all come down to binary in their storage format. Before we get to this, we first need to know how convert numbers to binary and understand each bit.
What is the denary equivalent of this number?
0  0  0 1 0 1
Step4:  Denary to Binary and Binary to Denary
Using the method in the slide above, we can convert by doing the following things
Step5:  Exercise
Find the 8 bit binary representation
<ASSISTANT_TASK:>
Python Code:
13 % 5 == 3
12 ** 2 == 144
146 % 67 == 12
19 % 8.5 == 2
4 ** (3 % 11)
Explanation: Math, Representation and Binary Arithmetic
Dr. Chris Gwilliams
gwilliamsc@cardiff.ac.uk
Contents
Mathematic Operations
Binary Conversion
Boolean Logic
Binary Arithmetic
Operations
We have covered (+, -, / and *), but there are more built in.
**: To the power of
% : Modulo
What is Modulo?
a % b
The remainder after a is divided by b
Exercise
Given three integers, write them in the order such that a % b = c or a ** b = c
13 3 5
2 144 12
67 12 146
2 8.5 19
BONUS MYSTERY QUESTION
Reorder and/or use the symbols to get an answer of 64
* 4 11 3 = 64
End of explanation
1024 `megabytes` = 1 `??`
1024 `gigabyte` = 1 `??`
1024 `terabyte` = 1 `??`
Explanation: Binary
A way of representing data using an ON or OFF flag using a 1 or a 0.
Why does it exist?
Because it the simplest method of storing information. A trivial yes or no can be stored, as well as whole novels (or programs, as you will be writing)
How, you ask?
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 ??
End of explanation
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)
Explanation: 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!
Exercise
How fast is your internet? Speed test it now or test the 4G on your phone.
How many mega bytes per second?
MB vs Mb
1 Megabit (Mb) is NOT equal to 1 Megabyte (MB)!
1 megabit = 1,000,000bits = 1/8 of a megabyte
Exercise
If I have a 3TB hard drive, how many 650 MB video files can I store on it?
End of explanation
32 16 8 4 2 1
--------------
0  0  0 1 0 1  
Explanation: Binary
Everything we store (movies, text, programs), all come down to binary in their storage format. Before we get to this, we first need to know how convert numbers to binary and understand each bit.
What is the denary equivalent of this number?
0  0  0 1 0 1
End of explanation
Yes. 
 16  8  4  2  1
 --------------
 1
Move to next bit. NUMBER = 27 - 16 = 11
Does 8 go into 11?
Yes.
16  8  4  2  1
--------------
1  1
Move to next bit. NUMBER = 9 - 8 = 1
Does 3 go into 4?
No.
16  8  4  2  1
--------------
1   1  0
Move to next bit. NUMBER still equals 1
Does 3 go into 2?
Yes.
16  8  4  2  1
--------------
1   1  0  1
Move to next bit. NUMBER still equals 1
Does 1 go into 1?
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
Explanation: Denary to Binary and Binary to Denary
Using the method in the slide above, we can convert by doing the following things:
1. Check the number of bits. 4 bit binary has 4 digits (0000), so we have a maximum of 15 numbers we can represent
2. Draw a table like the one in the previous slide for the number of bits
3. Check if the number you want to convert fits in to the left most bit:
    - If it does: add a 1 and subtract the number represented by the bit from the number you want to convert
    - If it does not: add a 0
4. Move along to the next bit and repeat step 3 until you get to the right most bit
Example
Convert 27 to binary.
5 bit binary can represent numbers up to 31, so we know our binary number has 5 bits.
 16  8  4  2  1
Start at 16, does 16 go into 27?
End of explanation
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)
Explanation: Exercise
Find the 8 bit binary representation:
* 127
* 2
* 64
* 79
* 34
Reverse engineer the approach to find the decimal representation of:
11101111
00011110
11110001
10101010
01010101
End of explanation
<END_TASK>