Presentation is loading. Please wait.

Presentation is loading. Please wait.

Week 3 - Monday CS 113.

Similar presentations


Presentation on theme: "Week 3 - Monday CS 113."— Presentation transcript:

1 Week 3 - Monday CS 113

2 Last time What did we talk about last time? Video games Lab 2

3 Project 1

4 Questions?

5 Lessons from Blown to Bits Chapter 1

6 Tanya Rider What is Tanya Rider's story?
How did bits (digital information) save her life? Why wasn't she saved earlier? Should she have been saved earlier?

7 What's a koan? Rhymes with "go on"
A koan is a puzzling or paradoxical statement If you think about it literally, you'll get nowhere, but if you think about it in just the right way… Insight! They are associated with the Zen school of Buddhism

8 Ganto's ax One day Tokusan told his student Ganto, "I have two monks who have been here for many years. Go and examine them." Ganto picked up an ax and went to the hut where the two monks were meditating. He raised the ax, saying, "If you say a word I will cut off your heads; and if you do not say a word, I will also cut off your heads." Both monks continued their meditation as if he had not spoken. Ganto dropped the ax and said, "You are true Zen students." He returned to Tokusan and related the incident. "I see your side well," Tokusan agreed, "but tell me, how is their side?" "Tozan may admit them," replied Ganto, "but they should not be admitted under Tokusan."

9 Koans of Bits It's all just bits Perfection is normal
There is want in the midst of plenty Processing is power More of the same can be a whole new thing Nothing goes away Bits move faster than thought

10 Bits and Bytes

11 Memory Storage for all the data and instructions on your computer
Modern computers store everything as binary digits (bits) which have a value of 0 or 1. 1 byte = 8 bits 1 kilobyte (kb) = 210 bytes 1 megabyte (mb) = 220 bytes 1 gigabyte (gb) = 230 bytes 1 terabyte (tb) = 240 bytes

12 Making sense of memory Memory What Can be Stored 1 byte
One character, like Q 4 gigabytes A regular movie on DVD 1 kilobyte A poem 8 gigabytes An action movie on DVD 100 kilobytes A short story 50 gigabytes A movie on Blu-Ray A low resolution photo 1 terabyte Two years of MP3 music 1 megabyte A novel 350,000 copies of War and Peace A medium resolution photo 250 DVD quality movies A minute of MP3 music 85,000 high resolution photos 1 gigabyte Two CD quality albums 24 albums of MP3 music

13 Data Representation

14 Data What if you want to write a program that can…
Edit music files Stream video from the Internet Organize your photo album Each of these tasks manipulates a lot of data MP3’s, streaming video, and jpegs are complicated kinds of data These kinds of data out of much simpler building blocks We'll start with representing numbers

15 Binary Hardware You have heard people (me, probably) talking about all the 1’s and 0’s inside of a computer What does that all really mean? Using semiconductor physics, we can make a tiny little piece of a microchip be in one of two states, say, OFF and ON, like a switch If we say that OFF is 0 and ON is 1, then, by using a lot of these switches, we can represent a lot of 1’s and 0’s

16 Binary Representation
What do we do with those 1’s and 0’s? To begin with, we represent numbers How many of you have heard of base 10? How many of you have heard of base 2? What’s the definition of a number system with a given base?

17 Numbers vs. numerals A number is a concept
Three hedgehogs, three complaints, and three notes of music all share threeness No matter how you represent a number, the number is the same The name for a number is called a numeral The following represent the concept of three: 3 III 112

18 Base 10 (decimal) numbers
Our normal number system is base 10 This means that our digits are: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 Base 10 means that you need 2 digits to represent ten, namely 1 and 0 Each place in the numeral as you move left corresponds to an increase by a factor of 10

19 3,482,931 Base 10 Example Ten thousands Hundreds Millions Ones Hundred
Tens

20 Base 2 (binary) numbers The binary number system is base 2
This means that its digits are: 0 and 1 Base 2 means that you need 2 digits to represent two, namely 1 and 0 Each place in the numeral as you move left corresponds to an increase by a factor of 2 instead of 10

21 11111100001 Base 2 Example Sixty fours 256’s Sixteens Fours 1024’s
Ones 512’s 128’s Thirty twos Eights Twos

22 So, what’s the value? = 1∙ ∙29 + 1∙28 + 1∙27 + 1∙ ∙25 + 0∙24 + 0∙23 + 0∙22 + 0∙21 + 1∙20 = = 2017

23 Converting from base 2 to base 10
Each 1 in a base 2 numeral represents a power of 2 Add up all those values

24 Converting from base 10 to base 2
Find the largest power of 2 that is less than or equal to the number Subtract that power of 2 from the number Repeat the process until you have zero Every time you used a power of 2, write a 1 in the representation of the number in base 2 Otherwise, write a 0

25 Bases Which base we use to represent numbers is arbitrary
We use base 10 almost certainly because we have 10 fingers The Duodecimal Society thinks we should use base 12 Is there a base 1? When do we use it?

26 Base 16 In case you were wondering, there are bases bigger (sometimes much bigger) than 10 Computer scientists like base 16 (hexadecimal) because it is easy between base 2 and base 16, but base 16 takes less space to write The digits in base 16 are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F 1A2 in base 16 is 418 in base 10 It is possible to write ridiculous numbers like DEADBEEF

27 What else? Using a series of 1s and 0s we can represent integers
Representing fractional numbers is similar, but messier As you know, we can represent colors as three numbers: red, green, and blue values What about words?

28 ASCII Table Each character has a number associated with it
These numbers can be listed in tables The ASCII table only covers 7 bits of information (0-127) Unicode is a standard that lets us represent characters from all the world's languages

29 Sounds You can think of sound as a wave
On a computer, we cannot record a wave form directly As usual, we have to figure out a way to store a wave as a series of numbers We are going to use these numbers to approximate the heights of the wave at various points

30 Sample rate Recall that Hertz (Hz) is a unit that means a number of times per second Equivalent to Hz is s-1 We are going to break down the wave into lots of slices We are going to have 44,100 slices in a second Thus, we are slicing at 44,100 Hz

31 Sample values We slice up a wave and record the height of the wave
Each height value is called a sample By getting 44,100 samples per second, we get a pretty accurate picture of the wave

32 Upcoming

33 Next time… We will talk about abstraction and variables
Read Chapter 1 of Python Programming

34 Reminders Keep working on Project 1
Read Chapter 1 of Python Programming


Download ppt "Week 3 - Monday CS 113."

Similar presentations


Ads by Google