Presentation is loading. Please wait.

Presentation is loading. Please wait.

Week 3 - Wednesday CS 113.

Similar presentations


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

1 Week 3 - Wednesday CS 113

2 Last time What did we talk about last time? Blown to Bits Chapter 1
Bits and bytes Base 2

3 Project 1

4 Questions?

5 Base practice Convert to base 10 Convert 458 to base 2

6 What else can we do with ones and zeroes?
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?

7 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

8 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

9 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

10 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

11 Abstraction Some content borrowed from the UC Berkeley course "The Beauty and Joy of Computing" designed by Dan Garcia

12 Abstraction Abstraction may be the most important idea in computer science We don't really care what your problem is, we want to solve it with computers by processing data We take your problem and look at it until we can see how it is similar to some other problem we know how to solve

13 A car metaphor What is a car? Lamborghini Aventador
Tires, chassis, body, engine, windows, doors Glass, nuts, bolts, steel beams Molecules Atoms Electrons, neutrons, and protons Quarks But if you want to fix the radiator, it is unhelpful to think of a car as electrons and protons

14 Progress! In many ways, progress leads us to more and more abstraction
Once upon a time, owning a car meant: Turning a crank to start the engine Replacing tires constantly Knowing how to work on most parts of the car Using manual transmission Now, many details are hidden, making it easier for the user

15 Interfaces Turn! Slow down! Go faster!
An interface (also called an abstraction barrier) is how you interact with a complex system, often technology What is the interface for a car? Turn! Slow down! Go faster!

16 Interfaces to computers
An interface hides some of the details of what's going on But it also makes it easier to get things done It feels like you are moving an orange cat around on the screen in Scratch In actuality, you're manipulating data inside the computer so that certain dots of light show up on the screen

17 A Taste of Python

18 Creative Commons Attribution-Share Alike 2.0 Generic License
Python Python is a programming language invented by Dutch programmer Guido Van Rossum Many language design decisions are because “Guido likes it that way” He now works for Google The abstractions for controlling the computer in Python are different from Scratch Image from Wikipedia, available:  Creative Commons Attribution-Share Alike 2.0 Generic License

19 GlowScript.org Python is an interpreted language
This means that the computer runs the code step by step unless there's a problem The most common environment for writing and executing Python code is IDLE Both Python and IDLE are free for download However, we will be using the web-based environment GlowScript.org

20 Typing out programs Scratch uses blocks that you fit together
Blocks are great because it's impossible to put together a program that doesn't make sense It might be useless, but the computer will know how to execute it In Python, you have to type out what you want the program to do We have the equivalent of blocks like if and repeat, but we have to type keywords instead of using blocks

21 Hello, world! The first program in many programming languages is called Hello, world It's a test to see if text input and output are working In Python, you can type the following to write the Hello, world program It will print Hello, world! on the next line print("Hello, world!")

22 Variables

23 Variables A variable is a very common abstraction in computer program
Think of a variable as a named box that holds a value Depending on the situation (and the rules of the language) a variable could hold: An integer like 14 A fractional number like 3.14 Text like "Where late the sweet birds sang" Lists of the above More complicated combinations of the above data Unlike in math, we can change the value in the variable as the program progresses

24 Variables in Python In Scratch, we can define a variable by going to the orange Data section and clicking the Make a Variable button In Python, we assign a value to a name and that's it The = sign is the assignment operator Think of it as an arrow that points left, storing whatever is on the right into the variable We can use whatever is stored in a variable like it's a value person = "Walter White" print(person)

25 Quiz

26 Upcoming

27 Next time… The physics of a ball moving through space Lab 3

28 Reminders Keep working on Project 1


Download ppt "Week 3 - Wednesday CS 113."

Similar presentations


Ads by Google