Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 102 Computers In Context (Multimedia)‏ 01 / 23 / 2009 Instructor: Michael Eckmann.

Similar presentations


Presentation on theme: "CS 102 Computers In Context (Multimedia)‏ 01 / 23 / 2009 Instructor: Michael Eckmann."— Presentation transcript:

1 CS 102 Computers In Context (Multimedia)‏ 01 / 23 / 2009 Instructor: Michael Eckmann

2 Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Today’s Topics Questions/comments? Chapter 1 material –What is computer science –Recipes –Programming Languages –Digital vs. Analog –Encodings

3 Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Recipes A few observations about cooking recipes –Should be followed closely by the chef Can't use ½ cup of salt instead of a ½ cup of sugar –Steps have an order to them For example, when making breaded chicken cutlets, you need to coat the chicken with the breading mixture before frying –Some steps aren't required to be ordered For example, if a recipe says to mix a tsp of salt, a tsp of garlic powder and a tbsp of pepper it doesn't matter whether you put the salt in before the pepper and mix them up.

4 Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Recipes A few observations about cooking recipes –It's sometimes possible to get the same exact results by following different recipes Not as true in cooking recipes as in algorithms, so the recipe analogy doesn't work perfectly here Sorting example

5 Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Recipes Computer scientists use programming languages or pseudocode (neutral) to specify recipes (aka algorithms/programs). You may have heard of various programming languages: Java, C++, C, C#, Python, Perl, Lisp, Scheme, Prolog, Fortran, Basic,... Some languages are better suited for certain tasks than others (e.g. C is speed efficient and has the ability to make very low level calls, therefore it is good for writing Operating Systems, Java is good for portable and safe/reliable code, therefore it is good for programs that might be run on multiple platforms.)‏

6 Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Languages Natural languages (like English) are not used to specify algorithms and programs because they are not precise enough. For example, a program written in a programming language needs to be able to mean the same thing, given the same code (sentence). In English the sentence: Time flies like an arrow. is ambiguous because it has multiple meanings (semantics) for the same syntax.

7 Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Languages Our text uses the Python programming language for several reasons –It's popular –It's relatively easy to learn –It's relatively easy to read –It's flexible –However, it's inefficient compared to solving the same problem in say C++.

8 Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Languages Python itself is a program (a program that interprets Python programs.)‏ Python is typically implemented in C. Jython is a python implementation in Java. –It provides a programmer with the ability to write python code and to use Java's classes Program source code (the code we write) is stored in plain text files. We could write python programs with a text editor, save them and run them with the python interpreter, however our text uses JES (Java Environment for Students) which allows entering code, debugging it and executing it. We'll use this software on Monday --- meet in HAR 207 for class.

9 Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Digital vs. Analog Anyone know the difference?

10 Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Digital vs. Analog Discrete values vs. Continuous Clocks Real life vs. movies Film cameras vs. digital cameras

11 Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Encodings At the lowest, most basic level, “Computers are electronic devices that react to voltages on wires.” (page 8, in Guzdial)‏ Some positive voltage is interpreted as (is encoded as) a 1 No voltage is interpreted as (is encoded as) a 0 One “wire” can either be encoded as a 0 or a 1 (we call this a bit)‏ So, a bit can either have the value 0 or 1, nothing else.

12 Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Encodings We often group bits together in groupings of eight, which we call a byte. A byte can have a value of –00000000 –00000001 –00000010 –00000011 –00000100 –00000101 –... –all the way up to and including –11111111 Anyone have any idea how many different patterns of 0's and 1's can be stored in a byte?

13 Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Encodings Computer memory (and hard disk space) is made up of bytes. Has anyone heard of the memory specifications for a PC like –contains 1 Meg of RAM –This means it has 1 Megabyte (MB) of memory –Anyone know what Mega means?

14 Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Encodings Computer memory (and hard disk space) is made up of bytes. Has anyone heard of the memory specifications for a PC like –contains 1 Meg of RAM –This means it has 1 Megabyte (MB) of memory –Anyone know what Mega means? –It means approximately 1 million –So, 1 MB is approximately 1 million bytes.

15 Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Encodings Why is it important to us to know about bytes? A byte is one of the basic units of space in a computer ( a bit is clearly more basic as it is a single 0 or 1, but we usually use bits in chunks of 8, which is a byte.)‏ Every file (e.g. Word Document, Image file, Sound file, plain text file, software program, etc.) is encoded in bytes. Plain text files are among the easiest (for us) to understand in terms of bytes --- every character takes up 1 byte of space. –ASCII character set

16 Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Encodings As an aside: –1 MB is approximately 1 million bytes. –I say approximately, because 1 million = 1000*1000, but 1 Meg is really 1024*1024.

17 Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Data Types The programs we write will work with various pieces of data. Data comes in different kinds. For example, we differentiate numeric data from text data. We need to because we can do different things with numbers than we can with text. –For instance, we can add, multiply, divide, etc. with numeric data, whereas dividing text like “CS102” / “Skidmore” doesn't make any sense. Common data types: –integer – whole numbers like -89, 0, 42, 987 –float – numbers that may contain a decimal like 3.1415, -2.1, 0.0, 8.0 –character strings – ordered list of characters like “Mike”, “Skidmore”, “3.14159”, “7”, “Hello, World!”


Download ppt "CS 102 Computers In Context (Multimedia)‏ 01 / 23 / 2009 Instructor: Michael Eckmann."

Similar presentations


Ads by Google