Welcome Back!


Learning Objectives for Today's Lesson

By the end of today's lesson, you will be able to...

  1. Name and describe the five main components of a computer.
  2. Describe the difference between hardware and software.
  3. Give the definition of an algorithm and write your own algorithms for tasks.
  4. Describe the difference between human and programming languages.
  5. Describe and define a compiler.
  6. Change numbers in the decimal system to the binary system and vice versa.


Announcements

  • Lab 1 due Friday at midnight
  • Waitlist roll - please see me during the break to sign in
  • How was the homework? Everything work out okay using Canvas?

A Little Computer Humor



Single Core Processor means only one processor (electronic circuitry in the computer) to execute program instructions. Read about multi-core processors here.

Main Components of a Computer

Background Information

  • Computer Science focuses on the design and creation of computer software
  • Computer Engineering focuses on the design and creation of computer hardware.
  • Although we are studying Computer Science (software), it is still important for us to have a general understanding of computer hardware.

Computer Hardware

    • Input device(s) - allow a user to communicate to a computer. Mouse, keyboard.
    • Output device(s) - allow computer to communicate to you. Screen (Monitor), Printer. Speakers.
    • CPU - Central Processing Unit - the "brain" of the computer. Executes programs, performs simple calculations, moves data from one memory location to another.



  • Main memory - Also known as RAM or Random Access Memory. This is the memory that people refer to when they say "How much memory does your computer have?" 
    • Main memory consists of numbered memory locations. Each location in memory is given an "address." The RAM can access each memory location directly by going to that "address." 
    • Think of the RAM as the computer's scratch paper or short term memory. It doesn't store information permanently there. But, uses the memory addresses to temporarily store information it needs as it does its calculations.



  • Secondary memory - This is the permanent memory. The hard disk, CDs, Flash drives, external hard drives. Can you think of anything else?
    • Memory here is stored as files. Secondary memory is generally slower because the computer must search through memory locations sequentially to find a file. Unlike the RAM, the computer cannot access a file directly by its address in secondary memory.

More Information

  • PC World article on the difference between the hard drive (HD) and a solid state drive (SSD)


Group Activity
As I hold up or point to objects in the room, tell me which of the 5 categories they fall under:
  1. Input devices
  2. Output devices
  3. CPU
  4. Main memory
  5. Secondary memory



Computer Software:

    • Program - a sequence of instructions given to a computer. These instructions are executed in order by the Central Processing Unit (CPU).
    • The computer follows the instructions in the program to complete some task.
    • Remember from Hour of Code, the instructions you gave your character were executed in order.


Algorithms

  • Programs are often based on algorithms which are converted into code by the programmer.
  • An algorithm is a sequence of precise instructions on how to accomplish a task
  • The process of developing algorithms is much in demand in today's computerized world
  • For example:
    • Game characters follow algorithms to respond to game events.
    • Medical equipment measures and monitors people's medical conditions following algorithms.
    • Day Traders on Wall Street write computer algorithms to decide when to buy and sell stocks.
  • In everyday life we can develop algorithmic solutions to natural problems and improve our lives.
  • For example, we may develop an algorithm for the easiest or most efficient way to get to school.
  • To develop an algorithm, we start with an analysis and decompose the problem into steps.
  • When we have an algorithm for one problem, we then generalize it to solve similar problems.
  • Examples of algorithms:
    1. A recipe is an algorithm created so others can replicate a dish
    2. When a composer writes music, she is creating an algorithm to play a song
    3. A coach creates a play in a team sport, like football or soccer, which is an algorithm for the players to follow during a game.
    4. In mathematics, people follow algorithms for math operations such as adding numbers with several columns of digits:
      1. Add the numbers in each column
      2. Then add the partial sums

How to Write an Algorithm

  • When we design algorithms, we need to write them simply so anyone can use them
  • This means that we cannot have long formulas or compound statements that are difficult to understand
  • Instead we must break everything down into simple steps
  • Every statement can only say how to do one simple thing
  • A good first approach is to work out an example. Then, try to generalize from the example.
  • As we will see, this is how computers work


Algorithm: Step by step instructions to solve a problem


Algorithm for Logging Into ATC Lab Computers

To Use the ATC Computers You Need to Create a Special Account:

  • Turn on the computer at your desk.
  • Press Ctrl + Alt + Delete
  • Read the legal notice and click "Ok"
  • The Business/CIS Account Request will be displayed.
  • Type "hello" and leave the password section blank.
  • Open up a browser of your choice (Firefox, Chrome, Internet Explorer, etc)
  • Navigate to the following site: https://reports.fhda.edu/php/stuact.php
  • Follow the directions to enter your 8-digit ID, Birth Month, Birth Day and 4-digit Birth Year.
  • Click on "Submit for Account Creation"
  • The computer will now check to see if you are enrolled.
  • Read the lab rules and click the check box in the lower left bottom corner to indicate that you accept and will participate.
  • Choose a Login Name -- suggested first initial followed by your last name.
  • Enter a password or your choice.
  • You will need to wait 5-10 minutes to use your new account.

cartoon image of people holding numbers

Group Activity! Designing Our First Algorithm

  • I need 6 volunteers to come up to the front.
  • Each person is giving a number.
  • Let's write an algorithm to organize everyone so that they are standing in ascending numerical order.
  • Do you think our algorithm is the only way to solve this problem?


image source

Activity 2.1: Sandwich Algorithm (10 pts)

  • Imagine that you have a friend who has never made a sandwich before.
  • Can you give step-by-step instructions for how to make a peanut butter sandwich?
  • Find a partner
  • Copy and paste the contents of this worksheet into a blank document (MS Word or another Google doc).
  • Write both your names at the top.
  • Fill in the remaining steps for making a sandwich
  • When you are finished, upload your worksheet to Canvas.
  • Important: Both partners need to submit to receive credit.


Programming Languages and the Compiler

  • What are some examples of languages you speak?
    • These languages are used to communicate with people.
  • Programming languages are similar to human languages, but are designed to communicate with machines.
    • Used to communicate instructions to the computer.
  • The problem: Computers only understand 1s and 0s.
  • Difficult for humans to understand 1s and 0s.
  • We need a translator!
  • C++ is a programming language which was created because it is easy for humans to use and understand. It is called a high-level language. Computers cannot understand C++ directly because the instructions are not written in 1s and 0s.
  • Other high level languages include Java, Python, C.
  • Instructions written in these languages are called source code.

The Compiler

  • Programs written in these languages need to be translated into a format the computer can understand.
  • Compiler is a program that translates a high-level language program, such as a C++ program, into a machine-language program that the computer can directly understand and execute.
  • Compilers are also useful because they let you know when you have made certain types of mistakes in your program.


Introduction to Binary Numbers - The Language Computers Understand

  • Video: How Computers Work Part 1
  • Bit = a binary digit = one 0 or 1 digit.
  • Byte = 8 bits
  • Why does a computer understand only 0s and 1s?
  • Understanding Base 10 (Decimal) (on white board)
  • Understanding Base 2 (Binary) (on white board)


(Image: Hobbit (1 hobit) Hobbyte (8 hobits). If you laugh, you pass the nerd test)

Group Activity: Binary Numbers

 I need 5 volunteers to come up to front of the class!

  • Each person will be given a piece of paper with 0 on one side 1 on the other.
  • Then, they will form a line with all 0s facing outward toward the class.
  • We will practice converting numbers from decimal to binary.

Wrap Up

  • With a partner, answer the following questions:
    1. What are the five main components of a computer?
    2. What is the difference between hardware and software?
    3. What is an algorithm?
    4. Why does a computer only understand 1s and 0s?
    5. What is the difference between human and programming languages?
    6. What is a compiler?


Upcoming Assignments

  • Lab 1: Due Friday at midnight on Canvas
  • Assignment 2: Due Tuesday at 9:20am on Canvas. 
~ Have a Great Weekend! ~