Introduction to Hardware the UNIX Command Line Interface

  • Slides: 24
Download presentation
Introduction to Hardware & the UNIX Command Line Interface Dr. Emily Hill

Introduction to Hardware & the UNIX Command Line Interface Dr. Emily Hill

How does a computer work? Introduction to computer hardware When programming a computer, it

How does a computer work? Introduction to computer hardware When programming a computer, it helps to have a basic understanding of the underlying hardware. Where do variables get stored? Where are functions or loops executed? How does all the data get converted into 0 s & 1 s?

Encoding Information There are 10 types of people in the world: those that understand

Encoding Information There are 10 types of people in the world: those that understand binary, and those who don’t

Computer Encoding How does a computer encode information? • Using 0 s and 1

Computer Encoding How does a computer encode information? • Using 0 s and 1 s (bits) • 1 bit can convey 2 pieces of information: – 1 or 0 – true or false – on or off – left or right

Exploring Bits • Raise your left hand for true, right hand for false: –

Exploring Bits • Raise your left hand for true, right hand for false: – 8/2=4 • How many pieces of information can be conveyed with 2 arms? • Multiple choice: the capital of NJ is… Left arm Right arm A. New York B. Princeton C. Trenton D. Montclair Up Down Up Up Down

Exploring Bits • Raise your left hand for true, right hand for false: –

Exploring Bits • Raise your left hand for true, right hand for false: – 8/2=4 • How many pieces of information can be conveyed with 2 arms? • Multiple choice: the capital of NJ is… Left arm Right arm A. New York B. Princeton C. Trenton D. Montclair 1 0 0 1 1 0 How many pieces of information can be conveyed with 2 arms?

Binary Numbers • Digital information is represented and stored in memory using the binary

Binary Numbers • Digital information is represented and stored in memory using the binary number system (as opposed to decimal) • A single binary digit (0 or 1) is called a bit • Devices that store and move information are cheaper and more reliable if they have to represent only two states • A single bit can represent two possible states, like a light bulb that is either on (1) or off (0) • Permutations of bits are used to store values – 2 arms = 2 bits (up/down) = 4 possible combinations (permutations) = 4 pieces (bits) of information

Bit Permutations 2 4 1 bit 2 bits 0 1 00 01 10 11

Bit Permutations 2 4 1 bit 2 bits 0 1 00 01 10 11 # Permutations (pieces of information): 8 3 bits 000 001 010 011 100 101 110 111 16 4 bits 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 Each additional bit doubles the number of possible permutations How many pieces of information (permutations) can you communicate with 1 hand (5 fingers)?

Bit Permutations • Each permutation can represent a particular item N • There are

Bit Permutations • Each permutation can represent a particular item N • There are 2 permutations of N bits • Therefore, N bits are needed to represent 2 unique items How many items can be represented by N 1 bit ? 21 = 2 items 2 bits ? 22 = 4 items 3 bits ? 23 = 8 items 4 bits ? 24 = 16 items 5 bits ? 25 = 32 items

Bit Permutations • How many fingers do you need to represent the alphabet (26

Bit Permutations • How many fingers do you need to represent the alphabet (26 letters)? • How much information can be encoded using 2 hands (10 fingers)? How many items can be represented by 6 bits ? 26 = 64 items 7 bits ? 27 = 128 items 8 bits ? 28 = 256 items 9 bits ? 29 = 512 items 10 bits ? 210 = 1024 items

Binary Conversions Binary -> Decimal -> Binary

Binary Conversions Binary -> Decimal -> Binary

Digital Information • Computers store all information digitally as bits: – numbers – text

Digital Information • Computers store all information digitally as bits: – numbers – text – graphics and images – audio – video – program instructions • In some way, all information is digitized - broken down into pieces and represented as numbers (which are encoded as bits)

Storing Bits in Memory • We’ve got all these bits to store information in

Storing Bits in Memory • We’ve got all these bits to store information in memory, but how do we access them? • How does the postman know where we live? • Computers use addresses to organize main memory & other storage devices • Bits typically grouped into sets of 8, called a byte

There are 10 types of people in the world: those that understand binary, and

There are 10 types of people in the world: those that understand binary, and those who don’t How many types of people are there?

Computer Hardware Components

Computer Hardware Components

Motherboard • Houses the computer components • Connects them via a bus:

Motherboard • Houses the computer components • Connects them via a bus:

Processor (aka CPU) • Executes program instructions • e. g. , performs arithmetic, runs

Processor (aka CPU) • Executes program instructions • e. g. , performs arithmetic, runs loops

Memory • Stores data & program instructions while programs execute • E. g. ,

Memory • Stores data & program instructions while programs execute • E. g. , stores variables and lists • Volatile: contents lost when computer turned off

Hard drive • Non-volatile: contents persist (saved) even when computer turned off • Stores

Hard drive • Non-volatile: contents persist (saved) even when computer turned off • Stores data and programs when not running

In this class, we’ll use UNIX to develop our python programs.

In this class, we’ll use UNIX to develop our python programs.

DEMO TIME

DEMO TIME

Basic UNIX commands • • • • ls: directory listing pwd: present working directory

Basic UNIX commands • • • • ls: directory listing pwd: present working directory cd: change directory cat: display (i. e. , concatenate) to the screen rm: remove cp: copy mv: move man: manual page touch: create an empty file zip: create a zipe file. : current directory. . : parent directory [tab]: autocomplete [↑]: previously entered command