Intro to Computer Science

Unit 0 - Introductions

  1. Introductions
  2. Hardware
  3. Software
  4. The Operating System: Desktop, Windows, Files, and Folders
  5. Computational Thinking
  6. Installing our Tools
  7. Encapsulation and Binary

0.0. Overview

In this Unit 0 introduction—did you know that computer scientists start counting not at 1, but at 0?—we'll introduce some fundamental computer concepts, discuss the idea of computation, and get things set up on your computer.

0.1. Introductions

Hi! I'm your instructor. You can learn a little about me if you look at the FAQs on our course website.

I don't know you yet, but I'm looking forward to getting to know you a little over the course of our time together in here. To help me get started on that, please fill out the Student Info form on our website. Thanks in advance!

0.1.1. The Course Website

Almost all of the course info is on the website, including:

The course schedule on the website lists what we're planning on covering each day in class, along with the assignments that you should be working on and turning in that evening. The assignments should be listed on MyPoly as well to help you in planning your work.

0.1.2. Course and Classroom Interactions

Some "classroom etiquette" for you.

0.2. Hardware

0.2.0. Overview

What are the physical components that make up a computing machine?

0.2.1. Anatomy of a Computer

Elements of a computer

The elements of a computer are typically the same, whether it's a laptop, a desktop, a server, a mainframe, a Raspberry Pi, or a smartphone.

  1. CPU—the brain of the computer that executes instructions, does math, and exchanges data with external devices and memory via a bus
  2. Memory Storage
    • Random Access Memory (RAM)—fast but expensive, loses data when power turns off.
    • Secondary storage—hard disk drives (HDD) and solid-state drives (SSD) are less expensive and persistent, but slower to access.
  3. Networks—wired or wireless, LAN or WAN
  4. Peripheral Devices—allow computer to be accessed by humans.
    • Keyboard
    • monitor
    • mouse / trackpad
    • speaker(s)
    • joystick
    • etc.

0.2.2. Caring for your laptop

Your laptop is a powerful tool, and an essential part of taking this course. Give it some love!

Don't throw it, drop it, or use it for a plate. Keep the screen and keyboard clean. Wrap the power cord up gently and store it carefully. Replace the battery, if needed. Don't fill up your entire hard drive. Restart your computer once in awhile. Avoid using the Chrome browser?

0.2.3. Other computer hardware you'll be using

Every time you use the Internet, your local computer or smartphone is interacting with computers that are located somewhere else on an extended network.

In this class you'll be interacting primarily with two other computers in addition to your own, "local" machine.

You're already using the crashwhite.com website, even as you read this. The other server, crashwhite.polytechnic.org, you'll learn about soon.

0.3. Software

0.3.0. Overview

Software is a general term for the programs that tell a computer how to solve a problem.

0.3.1. Programs

In order to function, computer hardware must be given a set of instructions— a program—to run. Programs are sometimes referred to as software.

Program

A program is a sequence of instructions that a computer carries out to achieve a given task.

The power of computers is that these instructions, all of them very simple, can be executed at ridiculously high speeds.

The focus of this course is to look at writing your own programs. We'll write our very first program soon.

0.3.1. Zeros and Ones - Binary Code

At the most fundamental level, computers run programs as binary code (written in 0s and 1s), and produce binary results (more 0s and 1s, sometimes represented by blinking lights) as output.

Fortunately for us, the gritty details of all of this are hidden away from us most of the time, encapsulated within the operating system and the high-level programs we'll be writing.

0.4. The Operating System: Desktop, Windows, Files, and Folders

0.4.0. Overview

One especially important collection of software is the operating system that interacts directly with the hardware to allow your computer to operate. Common operating systems include Windows, macOS, and Linux, and they each—in slightly different ways—give the user the ability to work with the computer's hardware.

While it's certainly possible interact with a computer using just 0s and 1s, almost nobody does that anymore. Over the years, computer scientists have built tools that make it much easier to give instructions to a computer: it's much easier to write code using normal numbers, text.

The operating system for a computer can be considered as one of these tools. It allows us to consider our data as being organized and presented using common metaphors: the "desktop," a "window," or a "folder." These aren't physical objects, of course, but analagous representations of those things.

0.4.1. The Desktop

Your computer screen, when you first log in, shows you a Desktop with a background image of some sort. This is a virtual area where you can temporarily keep files and folders that you're working on.

0.4.2. Windows

Because we like to think visually, you computer will almost always provide you with a window as part of a "graphical user interface". These windows can be moved and resized by clicking on their frames and dragging the mouse.

Applications typically have windows that you can use to interact with them. If you start Firefox, Chrome, or Safari, those web browsers display a window on the screen that you can use to surf the Internet. If you log into Google and open up a Doc or look at Gmail, the browser window is displaying the digital information there.

You can also minimize a window so that it is temporarily hidden from view. Clicking on the icon for that window will make it reappear on the screen. In order to be as efficient as possible, we're going to arrange our computer windows so that we can better see what's going on.

0.4.3. File System - Files and Folders

Your file system keeps track of all of the files that are stored in your computer's memory. You can "see" where these files are stored in a few different ways: they might be on the Desktop, as shown above, or you might open a file system window that will allow you to look through the computer's memory, as shown below.

Files are stored in "folders", or directories so that we can keep things more logically organized. The file system has its own directories that it uses, and you can make your own to more conveniently keep your stuff organized.

0.5. Computational Thinking

0.5.0. Overview

Computational thinking is a problem-solving process that involves critically analyzing problems and considering strategies for solving them, with special attention given to solutions that might involve using a computer.

Let's see exactly what that means.

0.5.1. Using Computers

We use computers to get digital things done. Sending email, surfing the Internet, streaming music, sharing updates on Facebook and Instagram. Most of us use a computer of one kind or another (smartphones are computers, too!) on a daily basis.

0.5.2. Programming Computers

Some people know how to program computers. Writing code to get the computer to do what you want it to do is a skill used by game programmers, website development teams, software engineers, and others who need to have a high degree of control over the computer and how it interacts with data.

Everybody needs to know how to use a computer. Does everybody need to know how to program a computer? Some high schools now require students to take a computer programming course as a graduation requirement, and some schools offer Foreign Language credit for learning a programming language.

Think about it

What do you think about computer programming? Should everyone know how to write a computer program? Why or why not? Give evidence to support your reasoning.

0.5.3. Computational Thinking

Somewhere between using computers and programming computers is the subject of computational thinking.

Definition: Computational Thinking

Computational thinking is a problem-solving process that involves critically analyzing problems and considering strategies for solving them, with special attention given to solutions that might involve using a computer.

Not everyone needs to program a computer... but using hardware and software is increasingly a part of most people's lives. When using computers, or engaging with others who use computers, some knowledge of computational thinking is essential for you to be able to participate in that discussion.

Computational Thinking is thought of by many people as "critical thinking with computers in mind." Problem analyses that take into account solutions that are especially efficient, or that may be suitable for adapting to computers, are often more useful than those that don't.

Example of Simple Computational Thinking

I have two different routes I can drive to get from my house to my local gas station, shown here:

Which route—the East route or the West route—is the better one to take, and why?

Show/hide solution

Solution:

The East route is shorter, but it requires me to take a series of left turns, including from my house (where I have to wait for both of lanes of traffic to clear), at each intersection (where I have to wait some more), and at the gas station as well.

The West route is a bit longer, but allows me to take right turns every step of the way. I only have to wait for one lane of traffic to clear before leaving my house, I can turn right on the red lights, and it's an easy right turn in to the gas station itself.

But the final answer may depend on other factors as well: What time of day is it? How bad is traffic? Is the sun rising or setting, making it hard for me to see when I'm driving in its direction?

We haven't gotten very deep into the idea of Computational Thinking, but something that we'll be seeing soon is the idea of an algorithm.

Definition: Algorithm

An algorithm is a series of systematic steps that can be used to solve a given category of problem.

So what advice would we give to our driver above?

Think About It: The Driving Algorithm

So what's the algorithm for the best route in going from one place to another (based on our example above)? What series of steps would we recommend?

Think about it for a moment before you click on the answer.

Show/hide solution

Solution:

One answer might be:

  • If there's not a lot of traffic, choose the route that travels the shortest distance.
  • If there IS a lot of traffic, choose the route that has the most right turns.

The average driver may not think about these things. And maybe a smart driver would think about these things, but only have to worry about it once in awhile.

But every time you use Google Maps, or Apple Maps, or Waze, or any GPS application on your phone or in your car, that program is looking at where you are, and where you want to go, and it's trying to figure out the best way for you to get there, based in part on at least some of these factors.

0.5.4. Computational Thinking at Scale

If you had to try to repeatedly solve the problem of quickly calculating the best route to a destination and get the answer right most of the time, you'd want to try to find an algorithm that you could code into the program.

And you would arrive at that algorithm using Computational Thinking.

Over the course of these few lessons, we'll be looking at some relatively simple and concrete examples of how Computational Thinking can by used to analyze a problem. These problems are designed to be interesting and manageable, and to illustrate the process of Computational Thinking.

It's important to understand, however, that Computational Thinking skills apply to problems of all scales. A simple question:

"What's the fastest route I should take to drive to a restaurant for lunch today?"

may use the same solution that would apply to a larger question that affects thousands or millions of people:

"How should Amazon most efficiently deliver 'Two Day Free Shipping' packages to clients?"

Some problems will have relatively simple solutions, some of them might be slightly more complex... and some problems that we try to solve have no known solutions (an interesting and frustrating fact).

Computational Thinking is ultimately about trying to wrap your head around a problem to figure out a way to solve it, especially if that solution involves some ordered or systematic process that can be implemented by computers.

0.5.7. Examples of Computational Thinking

EXAMPLE 1. COMPUTATIONAL THINKING ANALYSIS (Abstract)

Take a moment to watch the 5-minute video presentation here. Be sure to pause the video so that you can consider the questions being asked before going on to see the answer.

EXAMPLE 2. COMPUTATIONAL THINKING ANALYSIS (Applied)

Take a moment to watch the 5-minute video presentation here. Be sure to pause the video so that you can consider the questions being asked before going on to see the answer.

EXAMPLE 3. COMPUTATIONAL THINKING ANALYSIS (Applied)

1.c. Shopping for Groceries

Shopping for a list of groceries at the supermarket is a common task, and it can occupy a lot of time. What's the best way to go about shopping for groceries?

Consider the problem in terms of our Computational Thinking steps before looking at the solutions below.

  1. Problem Decomposition
    Breaking down data, processes, or problems into smaller, more manageable parts
  2. Pattern Recognition
    Observing and recognizing patterns or trends in data
  3. Abstraction/Model
    Identifying the general rules or principles that are responsible for those patterns or trends
  4. Algorithm Design
    Developing instructions or procedures that can be used to solve this problem and others like it

Show/hide analysis

Here's one Computational Thinking Analysis:

1. Problem Decomposition
There is a list of items, and those items are located in different parts of the grocery store.

2. Pattern Recognition
I have a random list of items to buy that aren't in any particular order. Items at the store do seem to be organized somewhat: dairy items are all in one area, cheeses are in another, and fruits and vegetables are in their own section. But those sections aren't located in consistent locations from store to store.

3. Abstraction/Model
There isn't much abstraction necessary for this analysis. The grocery list of items can be considered as a List or Array, a data structure that is used all the time in programming. The map of the store is simply an arrangement of locations that need to be visited.

4. Algorithm Design
There are two possible strategies that we might develop for doing our grocery shopping:

  1. Go down through the shopping list one item at a time, travelling to that part of the supermarket where that item can be found, and getting that item to put in the shopping cart. In this strategy, the list we're consulting is "in order"--we'll be assured of looking at each item on the list--but our visits to the various parts of the store are "disordered."
  2. Travel up and down the aisles of the supermarket, picking up items from the list as they are encountered. In this strategy, our traversal of the aisles is ordered--we're sure to visit each location in the supermarket--but our use of the grocery list itself is disordered.

1.d. Algorithm Efficiency

Which of these strategies is more efficient? Does the strategy that you choose depend on the length of the shopping list? The size of the store? The number of people you have helping you shop?

Show/hide solution

Searching algorithms don't just apply to things like buying groceries.

This graphic shows some of the different search strategies that might be employed when looking for an avalanche victim.

It's interesting that the Single Searcher pattern in this graphic looks just like my shopping strategy when I have a long list of items. Fortunately, the results of my shopping—finding where they keep the peanut butter—are a lot less critical then the results for rescue personnel.

Assignment: Lesson 2

To complete this lesson:

  1. Go to the Bebras Challenge, choose a Group level, and then take a few moments to solve any of the problems listed there (A problems are easiest, C problems are most challenging).
  2. Once you've arrived at a correct solution for each problem, (however many attempts it takes):
    1. Arrange your browser window and re-size it so that your problem solution is plainly visible on the left three-fourths of your screen.
    2. On the right one-fourth of your screen, your Desktop background and/or Desktop files should be plainly visible.
    3. Take a screenshot of the entire screen, including the browser window where you've been doing your work as well as part of your Desktop background. (This helps to identify your work.)
    4. Save your solution as ct1.png (or ct1.jpg, and then upload that solution to your forInstructor folder on the server.

0.6. Installing our Tools

0.6.0. Overview

Computers typically have a collection of applications that allow the user to interact with the operating system. Additional applications can be installed as needed.

For us, the applications that we're installing and using are specialized tools that we can use to create code, and to interact with the computer in a way that isn't possible with a commercial application. Here's what we need for our work in this course.

0.6.1. Windows Users

If you're using Microsoft Windows 10 or Windows 11, here is your checklist of things to do in preparation for this class.

  1. Install Linux Subsystem on Windows.
  2. Install Python 3.
  3. Install Visual Studio Code, a free, cross-platform editor (see VSCode [crashwhite] and How to Install VS Code [YouTube])
  4. Install Notepad++, a free text editor for Windows users (recommended).
 

0.6.2. macOS Users

If you're using Apple macOS, here is your checklist of things to do in preparation for this class.

  1. Install Python 3.
  2. Visual Studio Code, a free, cross-platform editor (see VSCode [crashwhite] and How to Install VS Code [YouTube])
  3. BBEdit, a free text editor for Mac users (recommended)
 

0.6.3. Linux Users

If you're using some variant of Linux (Ubuntu? Debian?), here is your checklist of things to do in preparation for this class.

  1. Install Python 3.
  2. Visual Studio Code, a free, cross-platform editor (see VSCode [crashwhite] and How to Install VS Code [YouTube])
 

0.6.4. The Terminal

The terminal is a program, a type of command-line interface that we can use to operate the computer.

The terminal is not the way that most people use a computer, but it's one of the way that programmers and developers use a computer.

Terminals are what hackers use. :) It is perhaps the fundamental tool that you should have some familiarity with. You'll be working with it every day in here!

Learn about the terminal and our server here.

0.7. Encapsulation and Binary

The idea of encapsulation is fundamental to computers, and to a number of other ideas. Generally speaking, "encapsulation" refers to the idea of building a container around something, as if that thing were contained in a capsule.

In the same way, the binary number system, consisting solely of 0s and 1s, is fundamental to how a computer works.

Take a moment to look through each of these presentations:

  1. Encapsulation
  2. Binary and Hexadecimal