Lesson 1-5 AP Computer Science Principles Binary Numbers Lesson 1-5 AP Computer Science Principles
Objectives Students will be able to: Describe how to use bits to create a functioning number system Understand the relationship between the powers of 2 and the number of bits needed to express a number of a certain magnitude. e.g. How many bits do I need to represent the number “15”, or “32”, or “1492”? Determine, for a given number of bits, both the number of possible numbers that can be represented and also the range of those numbers
Recall… In the previous lesson you created 27 different 3-place patterns out of circles, triangles and squares, and tried to define a system of rules to generate all of the patterns.
Journal What if you only had a circle and square? With only a circle and square, how many 3-place patterns are there? Here’s a start, you make the rest. How many are there?
Consider this… How large of numbers do you think this system can represent? How could we go higher?
Circle, Triangle, Square → Towards → The Binary Number System
1 place = 3, 1-shape patterns Previously on CSP…. 1 place = 3, 1-shape patterns Who: baker @TeachCode | #TeacherCon | #CSforAll
2 places = 9, 2-shape patterns Previously on CSP…. 2 places = 9, 2-shape patterns Who: baker @TeachCode | #TeacherCon | #CSforAll
2 places = 9, 2-shape patterns Previously on CSP…. 2 places = 9, 2-shape patterns Who: baker @TeachCode | #TeacherCon | #CSforAll
3 places = 27, 3-shape patterns Previously on CSP…. 3 places = 27, 3-shape patterns Who: baker @TeachCode | #TeacherCon | #CSforAll
3 places = 27, 3-shape patterns Previously on CSP…. 3 places = 27, 3-shape patterns Who: baker @TeachCode | #TeacherCon | #CSforAll
Number each pattern to make a shape -> number mapping Previously on CSP…. Number each pattern to make a shape -> number mapping 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Who: baker @TeachCode | #TeacherCon | #CSforAll
What if we had 10 shapes? Previously on CSP…. Who: baker @TeachCode | #TeacherCon | #CSforAll
1 place = Ten 1-shape patterns Previously on CSP…. 1 place = Ten 1-shape patterns 1 2 3 4 5 6 7 8 9 ← These are just shapes! Who: baker @TeachCode | #TeacherCon | #CSforAll
0 9 9 _ _ _ Quiz: What comes next? Previously on CSP…. Ten shapes 1 2 1 2 3 4 5 6 7 8 9 0 9 9 _ _ _ Who: baker @TeachCode | #TeacherCon | #CSforAll
0 9 9 _ _ _ 1 0 0 Quiz: What comes next? Previously on CSP…. Ten shapes 1 2 3 4 5 6 7 8 9 0 9 9 _ _ _ 1 0 0 Who: baker @TeachCode | #TeacherCon | #CSforAll
Place Values... Previously on CSP…. Who: baker @TeachCode | #TeacherCon | #CSforAll
__ __ __ __ __ __ Place Values... Previously on CSP…. Place Values... With Ten “shapes” every time you add a place, you multiply by 10 the number of numbers... __ 10 possibilities (0 - 9) __ __ 100 possibilities (00 - 99) __ __ __ 1000 possibilities (000 - 999) Who: baker @TeachCode | #TeacherCon | #CSforAll
__ __ __ __ __ __ Place Values... Previously on CSP…. Place Values... With Three “shapes” every time you add a place, you multiply by 3 the number of numbers... __ 3 possibilities ( ) __ __ 9 possibilities ( - ) __ __ __ 27 possibilities ( - ) Who: baker @TeachCode | #TeacherCon | #CSforAll
Four thousand and seventeen Previously on CSP…. Write the number… Four thousand and seventeen Who: baker @TeachCode | #TeacherCon | #CSforAll
4 0 1 7 Place Values...Remember what it means? Previously on CSP…. 4 0 1 7 1000s 100s 10s 1s 4 * 1000 + 0 * 100 + 1 * 10 + 7 * 1 4000 + 0 + 10 + 7 Who: baker @TeachCode | #TeacherCon | #CSforAll
Where is this heading? ...binary... Previously on CSP…. Who: baker @TeachCode | #TeacherCon | #CSforAll
01 “Binary” is a number system with 2 shapes... Previously on CSP…. Who: baker @TeachCode | #TeacherCon | #CSforAll
__ __ __ __ __ __ __ __ __ __ The pattern holds... Previously on CSP…. The pattern holds... With two “shapes” every time you add a place, you multiply by 2 the number of numbers... __ 2 possibilities (0 1) __ __ 4 possibilities (00 - 11) __ __ __ 8 possibilities (000 - 111) __ __ __ __ 16 possibilities (0000 - 1111) Who: baker @TeachCode | #TeacherCon | #CSforAll
1 1 0 1 Place Values...powers of 2 Previously on CSP…. 8s 4s 2s 1s 1 1 0 1 8s 4s 2s 1s 1 * 8 + 1 * 4 + 0 * 2 + 1* 1 8 + 4 + 0 + 1 = 13 Who: baker @TeachCode | #TeacherCon | #CSforAll
Previously on CSP…. Constructing a binary number means figuring out which powers of 2 add up to the number you want 128 64 32 16 8 4 2 1 Who: baker @TeachCode | #TeacherCon | #CSforAll
Previously on CSP…. Constructing a binary number means figuring out which powers of 2 add up to the number you want 128 64 32 16 8 4 2 1 0 0 1 0 1 0 0 1 32 + 8 + 1 = 41 Who: baker @TeachCode | #TeacherCon | #CSforAll
To the flippy do! Previously on CSP…. Who: baker @TeachCode | #TeacherCon | #CSforAll
Previously on CSP…. Flippy Do Quiz: What’s the binary number? 5 17 63 64 100 127 What’s the decimal number? 100 101 1101 1 0000 1010 1010 1111 1111 Who: baker @TeachCode | #TeacherCon | #CSforAll
Binary Odometer Go to the Binary Odometer (https://studio.code.org/s/csp1/stage/5/puzzle/2) See how it works… What’s the largest number you can make in binary with the binary odometer?” What happens when the odometer run out of numbers?
Activity Guide Complete the Activity Guide and turn it in.
Stage 5 Complete Stage 5.