Room 514

Classes, curriculum, education…

Programming in Practice March 31, 2008

Filed under: ICE3M,ICE4M — mryantho @ 11:46 am
Tags: ,

As I have already said, for class we will be using Ruby on Rails to explore elements of programming.  I have a new category about Ruby posts here on the blog.  I will post information about each lesson and tutorial we work through.  I will make videos as we go along, however, I will not post them here.  The reason is, I will use a lot of references from our book and that may pose some problems posting that in the public domain.  Instead I will email you the links to where I have posted the videos privately.

 

The Lightweight Introduction to Programming March 28, 2008

Filed under: ICE3M,ICE4M — mryantho @ 3:39 am
Tags:

Good morning Computer Scientists.  Read the following post and please summarize  for your own notes.

This a ultra-stripped down introduction to concepts in programming.  This is a starting point from no knowledge.  So if you come across this page and you have some background in programming, and you notice some things aren’t technically correct ~ you might care but my grade 11 students do not.  As a side note for my students, programmers tend to have serious idiosyncrasies (peculiar tendencies), a common one is the need to correct people when they feel a slight misinterpretation of their craft has been made.

Let’s start with some simple explanations of concepts in programming.  Many times I will use “real world” examples.  It isn’t that programming isn’t part of our reality, I mean that we have our every day world an the virtual one we are creating through programming.

Variables – A variable is something that represents something else.  It is that simple.  In math class when we say x+2 = 5, we are basically saying that x is representing a 3.  We could also say more generally that x is representing a number, integer, real number whole number, prime number etc.  A variable can also represent a word, a password might actually represent “iluvamericanidol.”  In real life, our name is a variable that represents us.  We’ll say “Jon Smith” rather than describe every characteristic that makes up John.  It is easier to use a variable.  You should name variables something meaningful like “person_height” rather than “z.”  You should know that you cannot name variables certain keywords.  Keywords are special words in the language that have special meaning.

Basic Data Types – Data can be different things.  Most often it is numbers and strings (letters, words, text.)  These are our basic types of data.  Later we’ll talk about advanced data types, but these are data types made of our basic ones.  Most programming languages have the following (or similar) basic data types.

  • Integers (ints) – These are whole numbers positive or negative (1, 34, -987)
  • Decimals (floats) – Decimal numbers (2.34, 4.00, -783.23)
  • Strings – Text and letters (“a”, “hello”, “jkhjhjj”)

Properties (Attributes) – Properties are things that an object has.  They are the things that describe the object and in most cases make it unique.  In real life we have trees.  Some properties of trees are colour, height, weight and type.  There are surely more, we’ll just look at these ones.   Colour is a property, if the colour of the tree is green, then the property colour has a value of “green.”  So properties have three parts, the property name, the value, and the type.  Types of properties are things like numbers, words, etc.  You can think of properties as special variables that belong to an object.

Objects – I should point out that in programming, Objects don’t exist in every programming language.  Languages like Squeak, Java, and C++ are “object oriented.”  That basically means that everything is an object (this is especially true in Java.)   languages like C and PERL are not object oriented, however, a skilled program can use constructs like objects if they wish.  An object is just something we represent in programming that is like its real life counterpart (or would be like if it existed.)  So if we were making the Need For Speed 30 car racing game, we might want to code a car object.  This car object would have properties, like weight, type, colour, etc.

IDE (Integrated Development Environment)– An IDE is where the programmer works.  If Word is for a writer, an IDE is for a programmer.  It allows programmers to write programs and usually provides helpful features.  This means it might have special display windows, or that it colour codes key words.  For most languages you don’t need a nice IDE and you could just use something like Notepad.  But a good IDE can really help you along.

Boolean Algebra– Boolean Algebra are like equations that can only have one of two results, either True or False.  In boolean algebra, something like 8 < 30 would equal True.  An expression like Brittney Spears AND Albert Einstein are both really smart, would be False because they are not BOTH smart (Albert Einstein is dead.)  The AND is called a boolean operator.

You’ll notice above that I used AND.   AND is a boolean operator.  We also have OR and NOT as the basic operators.  An expression like “I know how to drive a car OR I know how to fly a plane” would be True.  That is because I do know how to drive.  As long as one of the statements is True than the whole statement is true.  A NOT operator simply reverses the expression, so a true statement results in false and vice-versa.

Comparison Operators– These are operators that are also used in boolean algebra.  The expressions will still result in true or false.  In the example I used before: 8<30 is True, the “<” is a less-than operator.  These are often used to compare numbers but can also compare strings, or even objects.  We use the operators < (less-than), > (greater than), = (equal-to), and  != (not equal-to).

Functions (or Methods) – Functions are named chunks of code.  Programmers create functions to perform a job that the program will complete often.  That way instead of re-writing the same chunk of code over and over again.  That is the easiest thing to see.  Think about directions to school.  If we had to re-write code for each day of school, it adds up.  It is easier to have a function called “go_to_school,”  you’d never miss class again.

Functions also make our program more easy to understand when we look at it.  That’s because we name our functions things that makes sense.  So if we saw a function called “stringToInteger(x)”, we might guess that it converts the string x to an Integer.  As a side note these chunks of code are called blocks in Ruby.

Syntax– Syntax is the rules of a language.  English is a language and it has rules.  Those rules are called its grammar.  If we don’t use grammar correctly, even though we are using English words, our message will be lost.  The same is true for programming languages.  We need to follow the rules of our language or the computer won’t be able to understand what we want the program to do.  Every language has its own syntax.  Some programmers will have preferences and say one language’s syntax is more difficult than another language’s grammar.  And syntax can be tricky; forgetting a semi-colon may cause a whole program to crash.  And you thought English grammar was difficult.

Semantics – Remember when Homer said “Let’s not get bogged down in semantics.”?  I do…and I laughed.  Well, if there is something that can bog you down, it’s semantics.  Semantics is the meaning of a message.  Basically it’s what the message you are trying to get across.  While syntax is how you say something; semantics is what you are saying.  In programming, when we discuss semantics, we are talking about what you are trying to do with your program.  Are you trying to solve a complex calculation?  Create artificial intelligence for a game? Launch a space shuttle?  Getting your semantics correct, means creating a program that completes the correct steps to solve a task.

Visit this site: http://cisnet.baruch.cuny.edu/holowczak/classes/programming/ for some more information.  Use these explanations to add to your understanding.  Remember, you are expected to make notes…its is your homework.

Also for homework, visit this site: http://tryruby.hobix.com/ .  It will give you a very brief introduction to Ruby.  Don’t worry if a lot of it doesn’t make the most sense yet.  It will get better in time!

 

A Little More About Processors March 19, 2008

Filed under: ICE3M — mryantho @ 1:23 am
Tags: ,

Just a reminder that your test is Thursday March 20.

One thing we haven’t discussed in depth is how a processor works.  Part of that reason is that processor technology is rapidly changing.  With dual core and quad core CPU’s on the scene, there is a lot to talk about.  Some things that don’t change are the basics of the CPU.  We often refer to the CPU as the brain of the computer.  Well obviously that is a very big generalization (and for the most part, the CPU doesn’t “think”.)

So let’s take a bit of an in depth look at processors.  Intel (the leader in CPU sales) has some great information for students on their website.  Visit their lessons on processors here

I wouldn’t be surprised if there were a couple questions on your test relating to this material. 😉

 

Overview of Computer Components February 21, 2008

Filed under: computers,ICE3M — mryantho @ 4:59 pm
Tags:

Before we go any further, we should look at an overview of our computer components.  That way things will make some more sense when we look at any individual component at a deeper level 

Download this document with descriptions of computer components.

Task:

1. Open the above document, then:

  • Review
  • Highlight important parts, terms, etc. in yellow
  • Highlight confusing or non-understood terms in red

2.  In a similar style, add descriptions of:

  • Blu-Ray
  • Wireless Router
  • USB thumb drive
  • PCI-e

Save these all with pictures as a Word 97-2003 document.

3.  Create a Blog post that contains:

  • An introduction about the document you have created
  • A link to download the full version of the document
  • The text-only of the 4 component descriptions you have added
 

Motherboards February 20, 2008

Filed under: computers,ICE3M — mryantho @ 5:10 pm

Complete this note.

 

Inside the Computer February 19, 2008

Filed under: computers,ICE3M — mryantho @ 5:06 pm

Introduction 

Now that we have some fundamental knowledge about the history of computers, we can take a closer look at how the computers we use today work.  Computer components can seem complicated when we look at how they work.  It is important to make sure you understand the fundamentals as we move along.  Don’t forget to ask a question the moment something is unclear.  Either post a comment, or ask in class.

First Things First

I would like each ICE 3M student to send me an email to let me know their GMail address, and the URL of their blog.  Example:

From: firstname.lastname@gmail.com 

To: yanthoj2.deletethis@hcdsb.andthis.org

Subject: ICE3M  

Message:

Mr. Yantho,

This is firstname lastname, the address to my Blog is www.besticeblogever.wordpress.com.   

Regards,

Firstname Lastname  

PS You are the best teacher I have ever had.  I mean that in a serious way, not just to suck-up, because I know you hate suck-ups.  Also, good luck this year as you coach the senior girls soccer team to their third straight Halton Championship.

The Basic Computer

Conceptually, a computer is this:

Basic Comp

But we usually think of this:

Diagram

Homework: 

  1. Comment on your blog the difference between the two “ideas” of a computer.
  2. Download this PowerPoint
    1. Add slides as an introduction to the motherboard
    2. Identify each numbered component on the motherboard
    3. Explain (1-2 lines) what each component is
 

History of Computers February 14, 2008

Filed under: computers,ICE3M — mryantho @ 4:58 pm
Tags:

We have a bit of knowledge of how a computer stores numbers conceptually.  But before we move ahead, we should look at where we came from.  And be “we” I mean computers.  Take a look at this powerpoint presentation to get an introduction in to the history of computers.

 

Put A Hex on You February 12, 2008

Filed under: ICE3M — mryantho @ 3:13 pm
Tags: ,

It was very important to take a look at binary nunbers because they are fundamental in understanding how a computer works with data.  There is another number system, however, that we use in the field of computers quite often.  One of the most common areas most people see these types of numbers is in colour codes in graphics programs or on the web.  But we also use these numbers in computer engineering when we talk about things like memory locations.  The number system is hexadecimal.

Hexadecimal (or “hex” for short) is a base 16 number system.  Remember, decimal numbers are base 10, and binary numbers are base 2.  You should also remember that decimal numbers had ten digits (0-9) and binary had two digits (0-1).  Following that pattern, hex which is base 16 should have 16 digits.

Wait!  What’s After 9?

When we count in hex there has to be digits that represent higher numbers.  This is because we will be counting to the equivalent of 15 before we move to the next column of values.  Since we don’t have any single digit characters that are greater than 9, we use letters.  Specifically the letter A-F. 

Number Chart (decimal, binary, hex)This chart shows is the hex digits and there values in binary and in decimal.  These values are really important to remember because we will later look at how to not only convert hex to decimal numbers, but also how to convert hex numbers to binary.

One thing to notice is that when we represent a hex number in binary, we use 4 digits to do so.  This is common pratice, and is something you should get in the habit of doing.

Before we continue to converting decimal numbers to hex, let’s look at that common example of using hex.  Colour codes are usually written as a hex number.  They are also written as Red-Green-Blue, or RGB values.  This means that each colour (red, green, blue) is represented using two hex digits.  An example is: FF6633.  This represents an orange. 

paint bucketYou can think of it like a paint bucket – only a paint bucket where you add FF amount of red, 66 amount of green, and 33 amount of blue.  You’ll see these values when you use a program like Photoshop, or colours on web pages.  You can see what some of these colours look like here.

Counting by 16

Now that we have seen an example of how we use hex, we really should now what a hex number means and how we can convert a number from decimal format to hex.

Our conversion will work the same way it did in binary, except instead of using base 2 numbers, we are using base 16 numbers.  So our chart method for converting to binary will work, but now we write the powers of 16 instead of powers of 2.

Watch these two videos for examples on converting from decimal to hex, and back again:

Now you try….

Homework

  • Convert the following decimal numbers into hex: 18, 32, 165, 289, 342
  • Convert the following hex numbers into decimal: 3F, 2E, A4, 2C3, FFF
  • Thinking and Inquiry: How can we convert binary directly to hex (HINT: 2 to the power of 4 is 16).  This may involve some research.
 

ASCII Text & Codes February 11, 2008

Filed under: computers,ICE3M — mryantho @ 12:33 am
Tags: ,

The American Standard Code for Information Interchange (ASCII) is used by computers as a way to store letters as numbers (binary.)  But ASCII is actually older than the computer.  ASCII was created for teletype machines.  Teletype machines were like a cross between a typewriter and a fax machine (but these pre-date fax machines.)  The operator could type and the signals were carried to a receiver where a printer would interpret the codes in order to print to paper.  So ASCII was used interpret letters to signals to be transmitted, received and then printed.

 Question:  What is the importance of having a standard format?

See ASCII code chart here.

ASCII codes are obviously numbers, but we have to remember that they are actually stored as binary numbers.  So the capital letter “H” isn’t stored as 72, but rather as  1001000.  ASCII numbers are stored as 7 bit binary numbers.  This means that we have the lowest number as 0 (0000000) and a highest value of 127 (1111111) for a total range of 128.  This means we can have 128 ASCII characters. Seven might seem like a strange number because usually we use sets of eight bits.  Well in old computers, the 8th bit was used to check for errors, this was called a parity bit

Parity Bit?

So what exactly is a parity bit?  A parity bit was an extra bit used to check for errors.  Early forms of transmission would often have errors.  Of course, today when we transmit data (say, on a network) we still have errors.  An error in transmission often means that one digit is read wrong.  So the receiver thinks a digit is a one, when it should be a zero, or vice-versa.  A parity bit is an extra bit that can be set to either one or zero.  As an example, it is used to make sure that every group of 8 bits has an even or odd number of ones.  Let’s see an example:

Problem: Transmit the message: 0110101 1101011 0001101 1001101 0010100 with parity bits to try and check for errors.

Solution: Make each chunk of 7 digits have an even number of ones (even parity bit):

0110101 1101011 0001101 1001101 0010100 -> 00110101 11101011 10001101 01001101 00010100

Now each chunk of 8 bits has an even number of ones.  Each chunk is made of 7 bits of data, and 1 parity bit.

Unicode

What is Unicode? Well let’s go straight to the source: The Unicode Home Page:

Fundamentally, computers just deal with numbers. They store letters and other characters by assigning a number for each one. Before Unicode was invented, there were hundreds of different encoding systems for assigning these numbers. No single encoding could contain enough characters: for example, the European Union alone requires several different encodings to cover all its languages. Even for a single language like English no single encoding was adequate for all the letters, punctuation, and technical symbols in common use.

 So, while ASCII was good to represent all our English letters, it clearly isn’t enough to represent all the characters of all languages as binary numbers.

ASCII and Unicode aren’t the only way of encoding text, but they are two of the most popular and widely used methods.

Homework:

Decode the following messages manually & show your work (Due next class):

  1. 1001000 1000101 1001100 1001100 1001111
  2. 1001001 1000011 1000001 1001110 1010111 1001111 1010010 1001011 1001001 1010100 1001111 1010101 1010100

Assignment:

You will create an exemplar document (either by hand or electronically) showing how to perform binary addition and binary multiplication.  This should include one page for each addition and multiplication.  As this is an exemplar document, the main foucs is the example you use.  This means you should choose your example(s) wisely so that you can highlight the aspects of the process.

Due: Wednesday Feb 13

 

There are 10 types of people in the world…. February 8, 2008

Filed under: ICE3M — mryantho @ 4:49 pm

those who understand binary and those who don’t. 

Well, just like any number system there is a way to add numbers in binary.  Binary numbers might seem a bit confusing in general, but adding them is pretty easy.  We only have to remember a few simple rules.

The Rules of Adding

The rules look at the simplest case, adding two digits together.

  1. 0 + 0 = 0, carry 0
  2. 0 + 1 = 1, carry 0
  3. 1 + 1 = 1, carry 1

Keep that in mind as you take a look at this page.  It has an animation that explains this great.

Now that you understand binary addition, you’ll have no problem completing this worksheet.  This is due by next class.