Week 3 - Wednesday CS 113.

Slides:



Advertisements
Similar presentations
Summer Computing Workshop. Introduction to Variables Variables are used in every aspect of programming. They are used to store data the programmer needs.
Advertisements

CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
The Binary Numbering Systems
Connecting with Computer Science, 2e
Programming Introduction November 9 Unit 7. What is Programming? Besides being a huge industry? Programming is the process used to write computer programs.
Week 4-5 Java Programming. Loops What is a loop? Loop is code that repeats itself a certain number of times There are two types of loops: For loop Used.
Week 2 - Monday.  What did we talk about last time?  Software development  Lab 1.
General Programming Introduction to Computing Science and Programming I.
Chapter 2 Computer Hardware
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 6 Value- Returning Functions and Modules.
Documentation and Comments. What’s a comment? A comment is a simple form of documentation. Documentation is text that you the programmer write to explain.
Robert Crawford, MBA West Middle School.  Explain how the binary system is used by computers.  Describe how software is written and translated  Summarize.
1 Data Representation Characters, Integers and Real Numbers Binary Number System Octal Number System Hexadecimal Number System Powered by DeSiaMore.
Getting Started with MATLAB (part2) 1. Basic Data manipulation 2. Basic Data Understanding 1. The Binary System 2. The ASCII Table 3. Creating Good Variables.
8-1 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions.
Variables and Expressions CMSC 201. Today we start Python! Two ways to use python: You can write a program, as a series of instructions in a file, and.
Computer Control and Monitoring Today we will look at: What we mean by computer control Examples of computer control Sensors – analogue and digital Sampling.
11 Making Decisions in a Program Session 2.3. Session Overview  Introduce the idea of an algorithm  Show how a program can make logical decisions based.
PROBLEM SOLVING WARM-UP Fill in the spaces using any operation to solve the following (!, (), -/+,÷,×): = 6.
Week 3 - Monday.  What did we talk about last time?  Video games  Lab 2.
Unit 2 Technology Systems
Week 2 - Wednesday CS 121.
Development Environment
More about comments Review Single Line Comments The # sign is for comments. A comment is a line of text that Python won’t try to run as code. Its just.
Introduction to Computing Science and Programming I
Create a Halloween Computer Game in Scratch
Lec 3: Data Representation
A Python Tour: Just a Brief Introduction
Scratch for Interactivity
GCSE COMPUTER SCIENCE Practical Programming using Python
Week 3 - Monday CS 113.
GCSE COMPUTER SCIENCE Practical Programming using Python
Learning to Program D is for Digital.
Introduction to Python
CMSC201 Computer Science I for Majors Lecture 22 – Binary (and More)
Week 3 - Friday CS222.
Formatting Output.
Week 2 - Friday CS 113.
Lesson 1 An Introduction
Week 7 - Wednesday CS 121.
IF statements.
Intro to PHP & Variables
Chapter 16 – Programming your App’s Memory
Procedural Abstraction Object-Oriented Code
Learning to program with Logo
Colors.
Subroutines Idea: useful code can be saved and re-used, with different data values Example: Our function to find the largest element of an array might.
Introduction to Python
First Python Program Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming: An.
Introduction to Programming
Coding Concepts (Data- Types)
Introduction to Programming
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
Chapter 17 Looking “Under the Hood”
Tonga Institute of Higher Education IT 141: Information Systems
Tonga Institute of Higher Education IT 141: Information Systems
Chapter 2 – part a Brent M. Dingle Texas A&M University
Selection Statements Chapter 3.
Introduction to Programming
Chapter 1 Introducing Small Basic
Introduction to Programming
Creating a Simple Game in Scratch
1.3.7 High- and low-level languages and their translators
Class code for pythonroom.com cchsp2cs
Dasar-Dasar Pemrograman 2: Java Basics
Primary School Computing
Week 7 - Friday CS 113.
Week 1 - Friday COMP 1600.
Presentation transcript:

Week 3 - Wednesday CS 113

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

Project 1

Questions?

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

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?

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

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

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

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

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

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

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

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

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!

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

A Taste of Python

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: http://en.wikipedia.org/wiki/File:Guido_van_Rossum_OSCON_2006.jpg  Creative Commons Attribution-Share Alike 2.0 Generic License

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

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

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!")

Variables

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

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)

Quiz

Upcoming

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

Reminders Keep working on Project 1