Block B

The Littleendian Method Yesterday we learned how to convert bases with the bigendian metod. We begain at the "big end" and worked our way down.

Now consder this.



69    *1        Since 69 is odd, we know its binary expansion ends in a 1.
                The * is a wildcard representing any glob of 0s and 1s.
34    *01       69//2 = 34. this chops  the last digit off.
                It reveals the second to last digit is a 0.
17    *101      Repeat this procedure until you whittle down to 0.
8     *0101
4     *00101
2     *000101
1     *1000101
0     1000101  We have all of the digits!

Now let's try this on base 5.

69    *4      69%5 = 4
13    *34     69//13 = 5 and 13%5 = 3.
2     *234    13//5 = 3 and 2%5 = 2
0     234     we have the digits.

In any base b,

Let's convert 121 into octal and binary.

Base 8:  0o171       (0o is a prefix meaning "this is an octal number")
Base 2:  0b1111001

Packing-Unpacking Procedure packing: hree bits pack into one octal digit because 23 = 8. 1 111 001 1 7 1 → 0o171 Unpacking 1 7 1 001 111 001 0b1111001 Hexadecimal {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F} 0xa4b a 4 b 1010 0100 1011 0b101001001011 Packing is the same as octal.

A Base Changing Practicepalooza

Hex Numbers and Colors Download colorDemo.zip from the navigation bar on the left. Decompress it and open the files with VSCode. Look in the CSS file, and you will see this.


/*Author: Morrison*/
h1, h2, .display
{
    text-align:center;
}
body
{
    background-color:#FFFFFF;
}

Change the 6-digit hex number inside of the body style rule. Then, in your browser, choose File → Open... and open the HTML file. Let's pool our knowledge.

redFF0000
green
blue0000FF
yellowFFFF00
black000000
whiteFFFFFF
magentaFF00FF
cyan00FFFFF

Playing with Pythons

What is an object? An object is an item stored in memory. Objects have three attributes.

All data in Python are represented as objects. Python, like every other language, has a type ecosystem. In this portion of the course, we will being by learning about Python's scalar types. Later, we will address sequences, sets, and dictionaries.

Your class's Python session is in the file 0203B.txt which you can download from the navigation area.

The Number Types