79
Computer Science 1 Week 2

Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts Input & Output

Embed Size (px)

Citation preview

Page 1: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

Computer Science 1Week 2

Page 2: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

This Week ...This Week ...

• QBasic ProgrammingQBasic Programming• Computer ConceptsComputer Concepts

Input & Output DevicesInput & Output Devices Binary NumbersBinary Numbers Computer PortsComputer Ports

Page 3: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

QBasic QBasic IntroductionIntroduction

The Basics of QBasicThe Basics of QBasic

Page 4: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Overview of QBasicOverview of QBasic

• A simple programming language A simple programming language designed to teach programming conceptsdesigned to teach programming concepts evolved over timeevolved over time

• Eventually evolved into Visual Basic .NETEventually evolved into Visual Basic .NET one of the most sophisticated languages in useone of the most sophisticated languages in use your skills may be useful lateryour skills may be useful later

Page 5: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

How You Will How You Will ProgramProgram

• QBasic programs are simply text documents.QBasic programs are simply text documents.• You program by writing out instructions in a sequence, You program by writing out instructions in a sequence,

the computer then runs them.the computer then runs them.• After you write your program you will need to test it.After you write your program you will need to test it.• When your program works as specified, save it as When your program works as specified, save it as

lab1.qblab1.qb, and turn in the program in SacCT., and turn in the program in SacCT.• The assignments will gradually get more challenging.The assignments will gradually get more challenging.

Page 6: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

QBasic LiteQBasic LiteMain WindowMain Window

HelpRun Print

Page 7: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

QBasic LiteQBasic LiteProgram Output WindowProgram Output Window

Save OutputPrint

Page 8: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Types of Data in QBasicTypes of Data in QBasic

• NumericNumeric Integer, floating pointInteger, floating point

• StringsStrings Used for Used for texttext String values are in String values are in ""double-double-

quotesquotes""

Page 9: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Examples of NumbersExamples of Numbers

• 55• 1.51.5• 100100• 3.143.14• 18501850

Page 10: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Examples of StringsExamples of Strings

• "Sac State""Sac State"• "Computer Science 1""Computer Science 1"• "Hornet""Hornet"• "1850""1850"

Page 11: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

QBasic StatementsQBasic Statements

• A A programprogram consists of a series of consists of a series of statementsstatements

• Statements have some key Statements have some key reserved words and can be in reserved words and can be in upper case or lower case in upper case or lower case in QBasicQBasic

• Statements are executed in orderStatements are executed in order From the first listed to the lastFrom the first listed to the last QBasic follows your instructions exactly as QBasic follows your instructions exactly as

they appear in your programthey appear in your program

Page 12: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

QBasic StatementsQBasic Statements

• Each tells QBasic to:Each tells QBasic to: Input data, orInput data, or Output (display) data, orOutput (display) data, or Process data, or Process data, or Store / Retrieve DataStore / Retrieve Data

Page 13: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Functions of a Functions of a ComputerComputer

Output Data

Page 14: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

PrintPrint Statement Statement

• Used to output data to Used to output data to the the screenscreen

• Can be used to output Can be used to output numbers and textnumbers and text

• Not to the printerNot to the printer

Page 15: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

PRINT Stuff

PrintPrint Statement Statement SyntaxSyntax

Starts with PRINT

Numbers and Strings

Page 16: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Example 1: Program having one Example 1: Program having one PRINT statement PRINT statement

PRINT "Go Hornets!"

String

Page 17: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Its OutputIts Output

Go Hornets!

Page 18: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Print Example 2Print Example 2

PRINT 1947Number

Page 19: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Print Example 2Print Example 2OutputOutput

1947

Page 20: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Print Statement:Print Statement:The SemicolonThe Semicolon

• Used in the Used in the Print StatementPrint Statement

• Tells QBasic to append several items so that Tells QBasic to append several items so that they will be displayed right next to each they will be displayed right next to each other other

Page 21: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

PRINT "Sac" ;; "State"PRINT

PRINT "... rocks!"

PRINT "Sac" ;; "State"PRINT

PRINT "... rocks!"

Semicolon ExampleSemicolon Example

Page 22: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

SacState

... rocks!

Semicolon Example Semicolon Example OutputOutput

No space?

Page 23: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

PRINT "Sac" ; "State"

PRINT

PRINT "... rocks!"

Semicolon ExampleSemicolon Example

There is no space

Page 24: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

The CommaThe Comma

• Used to align data into desirable Used to align data into desirable format format

• The The Print StatementPrint Statement will display will display information in different information in different columnscolumns

• This is quite useful for creating This is quite useful for creating nice formatted output!nice formatted output!

Page 25: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Comma Example 1Comma Example 1

PRINT “Team 1",“Team 2"

PRINT “Sac State",“Idaho"

Page 26: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Comma Example 1Comma Example 1OutputOutput

Team 1 Team 2

Sac State Idaho

Page 27: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Comma Example 2Comma Example 2

PRINT "Cherry", "Red“

PRINT "Lemon", "Yellow"

PRINT "Chocolate", "Brown"

Page 28: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Comma Example 2Comma Example 2OutputOutput

Cherry Red

Lemon Yellow

Chocolate Brown

Page 29: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

PRINT "University:", "Sac State"PRINT "Mascot:", "Hornet"PRINT "Colors:", "Green & Gold"PRINT "Founded:", "1947"

Comma Example 3Comma Example 3

Page 30: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

University: Sac State

Mascot: Hornet

Colors: Green & Gold

Founded: 1947

Comma Example 3Comma Example 3OutputOutput

Page 31: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

PrintPrint Statement Statement SummarySummary

• Commas:Commas: put items into put items into columnscolumns excellent for formatted outputexcellent for formatted output

• Semicolons:Semicolons: put items put items nextnext to each other to each other excellent for combining informationexcellent for combining information

Page 32: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

ClsCls Statement Statement

• Used to Used to clclear ear the the sscreencreen

• Any information on Any information on the output screen will the output screen will disappeardisappear

Page 33: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

CLS

Cls Cls Statement SyntaxStatement Syntax

Pretty simple!

Page 34: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

PRINT "You won’t see this."

CLS

PRINT “Really?!"

Cls ExampleCls Example

Page 35: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Really?!

Cls ExampleCls Example

Poof! The output before CLS was cleared

Page 36: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

RemRem Statement Statement

• Used to add comments Used to add comments ((remremarks) to your programarks) to your program

• They don't do anythingThey don't do anything• Makes programs easier to readMakes programs easier to read• They start with either They start with either REMREM or a or a

single quote single quote

Page 37: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

REM Computer Science 1

REM Joe Gunchy

REM Lab 1

PRINT “Hello, World”

Rem ExampleRem Example

Page 38: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

' I am a remark

' Computer Science 1

' Sac State

' Lab #1

Rem Example 2Rem Example 2

Page 39: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

How to create your first programHow to create your first program

1.1. Install (if necessary) and run Install (if necessary) and run QBasic.QBasic.2.2. The information box at the start is optional.The information box at the start is optional.3.3. Type your program into the main window.Type your program into the main window.4.4. Test your program by clicking the “run” button.Test your program by clicking the “run” button.5.5. If it works, you should save it to a file.If it works, you should save it to a file.

>> make sure you are saving the >> make sure you are saving the programprogram window, not the output! window, not the output!

6.6. If it doesn’t work quite right, fix it and try again!If it doesn’t work quite right, fix it and try again!7.7. If you prefer, you can type your program using another If you prefer, you can type your program using another

editor, and load it into QBasic by choosing “open”.editor, and load it into QBasic by choosing “open”.

Page 40: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

QBasic LabQBasic Lab

Your First Program – Hello World!Your First Program – Hello World!

Page 41: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Lab: Hello WorldLab: Hello World

• ObjectivesObjectives get to know the QBasic Lite applicationget to know the QBasic Lite application output data using the output data using the Print StatementPrint Statement

• Submit your program to:Submit your program to: Submit it as an Submit it as an attachmentattachment to Lab 1 in SacCT to Lab 1 in SacCT make sure your saved program file has a “.qb” extension DUE DATE: indicated in the lab handoutDUE DATE: indicated in the lab handout

Page 42: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Page 43: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

Input & Output Input & Output DevicesDevices

Bridging the Digital and Analog WorldBridging the Digital and Analog World

Page 44: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Functions of a Functions of a ComputerComputer

Output Data

Input Data

Store Data

Process Data

Page 45: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Analog Digital

Functions of a Functions of a ComputerComputer

Page 46: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Basic Input DevicesBasic Input Devices

• KeyboardKeyboard• MouseMouse• TouchpadTouchpad

used primarily on laptopsused primarily on laptops replacement for the mousereplacement for the mouse

• Trackball Trackball similar to a mousesimilar to a mouse

Page 47: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

MonitorsMonitors

• CRTCRT CCathode athode RRay ay TTubeube This is the classic TV screenThis is the classic TV screen

• LCD LCD LLiquid iquid CCrystal rystal DDisplayisplay Clearer, low radiation emission, portable, and Clearer, low radiation emission, portable, and

compactcompact

• LED LED LLight ight EEmitting mitting DDiodeiode Efficient, color, size, long lifetimeEfficient, color, size, long lifetime

Page 48: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Ink Jet PrintersInk Jet Printers

• Nozzle-like print head Nozzle-like print head Sprays ink onto paper to form Sprays ink onto paper to form

characters and graphicscharacters and graphics• Most use CMYK colorMost use CMYK color

CCyan-yan-MMagenta-agenta-YYellow & ellow & BBlacklack

Page 49: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Laser PrintersLaser Printers

• Use a laser to paint dotsUse a laser to paint dots Particles fly on the laserParticles fly on the laser "Ink" is dry – called "Ink" is dry – called dry tonerdry toner

• Higher quality than ink jet Higher quality than ink jet • More expensive to buy More expensive to buy • Less expensive to operateLess expensive to operate

Page 50: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Dot Matrix PrintersDot Matrix Printers

• Uses a grid of wires to printUses a grid of wires to print impact the paper through a ribbonimpact the paper through a ribbon same principle as a typewritersame principle as a typewriter

• Used rarely nowadaysUsed rarely nowadays for for low-qualitylow-quality output output to print multipart carbon formsto print multipart carbon forms

Page 51: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Dot Matrix PrintersDot Matrix Printers

Write Head

Page 52: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Page 53: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

How do How do computers store computers store

numbers numbers

Binary EncodingBinary Encoding

Page 54: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

What is a Number?What is a Number?

• The Numeric System we useThe Numeric System we use positional grouping systempositional grouping system each position represents a power of 10each position represents a power of 10

• Binary numbersBinary numbers but use powers of but use powers of 22 rather than 10rather than 10

Page 55: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Base 10 Numbers Base 10 Numbers (decimal numbers)(decimal numbers)

The number The number 17831783 is ... is ...

104 103 102 101 100

10000 1000 100 10 13

1000 + 700 + 80 + 3 = 17831000 + 700 + 80 + 3 = 1783

8710

Page 56: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Binary NumbersBinary NumbersExampleExample

The number The number 0110 10010110 1001 is ... is ...

27 26 25 24 23 22 21 20

128 64 32 16 8 4 2 1

1

64 + 32 + 8 + 1 = 10564 + 32 + 8 + 1 = 105

0010110

Page 57: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Binary NumbersBinary NumbersExample 2Example 2

The number The number 1100 10111100 1011 is ... is ...

128 + 64 + 8 + 2 + 1 = 203128 + 64 + 8 + 2 + 1 = 203

27 26 25 24 23 22 21 20

128 64 32 16 8 4 2 1

11010011

Page 58: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Page 59: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

How do How do computers store computers store

other types of other types of data data

Binary Encoding againBinary Encoding again

Page 60: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

How Data is How Data is RepresentedRepresented

• Data representationData representation how letters, sounds, images, etc… are storedhow letters, sounds, images, etc… are stored

• A A digital devicedigital device works with the symbolic world, say, in a computerworks with the symbolic world, say, in a computer

• An An analog deviceanalog device works with the physical worldworks with the physical world the world we live inthe world we live in

Page 61: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Digital RepresentationDigital Representation

• Computers are digital Computers are digital Work with Work with 11's and 's and 00's's Binary systemBinary system

• Just as a standard light ...Just as a standard light ... Switch – two symbols – on and offSwitch – two symbols – on and off Dimmer – not digital – the value is Dimmer – not digital – the value is

depends on the physical universedepends on the physical universe

Page 62: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Bits & BytesBits & Bytes

• A bit is one binary digit A bit is one binary digit Either 1 or 0Either 1 or 0 The most basic symbol used in computersThe most basic symbol used in computers Shorthand for a bit is Shorthand for a bit is bb

• A byte is 8 bits A byte is 8 bits e.g. e.g. 0010 01000010 0100 The basic group of symbols used in computersThe basic group of symbols used in computers Shorthand for a byte is Shorthand for a byte is BB

Page 63: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Bits & BytesBits & Bytes

• Are used to represent Are used to represent everythingeverything

• Examples:Examples: NumbersNumbers Letters, punctuation, etc...Letters, punctuation, etc... PicturesPictures SoundsSounds

Page 64: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Quantities of Bits & Quantities of Bits & BytesBytes

• BitsBits Kilobit (Kilobit (KbKb) is ) is 1,0241,024 bits bits

• BytesBytes Kilobyte (Kilobyte (KBKB) is ) is 1,0241,024 bytes bytes Megabyte (Megabyte (MBMB) is ) is 1,048,5761,048,576 bytes bytes Gigabyte (Gigabyte (GBGB) is ) is 1,073,741,8241,073,741,824 bytes bytes

Page 65: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Page 66: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

ComputerComputerPortsPorts

Connecting Devices to Your ComputerConnecting Devices to Your Computer

Page 67: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Expansion PortsExpansion Ports

• Used to connect a Used to connect a peripheral deviceperipheral device

• Expansion portExpansion port – any – any connector that passes data connector that passes data in and out of a computer or in and out of a computer or peripheral deviceperipheral device

Page 68: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

How Fast is a Port?How Fast is a Port?

• Different ports have different speedsDifferent ports have different speeds different ports use different technologydifferent ports use different technology generally have become generally have become fasterfaster over time over time

• How speed is measuredHow speed is measured number of bits transferred over timenumber of bits transferred over time kilobits per second (kilobits per second (KbpsKbps) : ) : 1,024 1,024 megabits per seconds (megabits per seconds (MbpsMbps) : ) : 1,048,5761,048,576

Page 69: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Original PortsOriginal Ports

• SerialSerial was the first microcomputer port was the first microcomputer port been around since the 70'sbeen around since the 70's slow – slow – 56 Kbps56 Kbps

• ParallelParallel faster– faster– 12 Mbps (12,000 Kbps)12 Mbps (12,000 Kbps) was primarily used for printerswas primarily used for printers not used anymorenot used anymore

Page 70: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

The PS/2 PortThe PS/2 Port

• Released in 1987 by IBMReleased in 1987 by IBM• Still used todayStill used today

KeyboardsKeyboards Mouse – sometimesMouse – sometimes

• LimitationsLimitations keyboard & mouse ports are dedicatedkeyboard & mouse ports are dedicated do do notnot remove cables while running remove cables while running

Page 71: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Monitor PortsMonitor Ports

• VGA VGA VVideo ideo GGraphics raphics AArrayrray sends sends analoganalog data data looks like a serial port, but 15 pinlooks like a serial port, but 15 pin

• DVIDVI DDigital igital VVisual isual IInterface nterface sends sends digitaldigital data data used with LCD monitorsused with LCD monitors

Page 72: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

The FireWire PortThe FireWire Port

• Also called Also called IEEE 1394IEEE 1394• Created by AppleCreated by Apple• Designed to transfer Designed to transfer

multimedia datamultimedia data• VersionsVersions

Firewire 400 – Firewire 400 – 400 Mbps400 Mbps Firewire 800 – new – Firewire 800 – new – 800 Mbps800 Mbps

Page 73: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

The USB PortThe USB Port

• UUniversal niversal SSerial erial BBusus• USB Implementers ForumUSB Implementers Forum

hundreds of companieshundreds of companies in charge of standardsin charge of standards

• Major Features:Major Features: plug and playplug and play ports are interchangeableports are interchangeable can be "daisy chained"can be "daisy chained"

Page 74: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

USB Version 1.1USB Version 1.1

• Main developers:Main developers: Apple ComputerApple Computer Hewlett-PackardHewlett-Packard IntelIntel MicrosoftMicrosoft NECNEC

• Released in 1996Released in 1996• Speed: Speed: 12 Mbps12 Mbps – not that fast – not that fast

Page 75: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

USB Version 2.0USB Version 2.0

• Designed to be Designed to be hi-speedhi-speed• Developers:Developers:

Hewlett-PackardHewlett-Packard IntelIntel LucentLucent MicrosoftMicrosoft NECNEC Philips Philips

Page 76: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

USB Version 2.0USB Version 2.0

• Released in 2001Released in 2001• Speed: Speed: 480 Mbps480 Mbps

4040 times faster than USB 1.1 times faster than USB 1.1 8080 Mbps faster than FireWire! Mbps faster than FireWire! backwards and forward backwards and forward

compatible!compatible!• Is becoming the Is becoming the onlyonly port port

Page 77: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Computer Port GuideComputer Port Guide

The more - the betterYes!USBUseful for old hardwareMaybeFireWire

Great for digital monitorsMaybeDVIWidely used for monitorsYesVGA

Used for keyboardsProbablyPS/2ObsoleteNoParallelObsoleteNoSerial

NotesNeed It?Port

Page 78: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State

Computer Ports Computer Ports Through TimeThrough Time

USBDidn't exist!Flash DriveUSBGameJoystickUSBParallelScannerUSBParallelPrinter

VGA or DVIVGAMonitorPS / 2 or USBPS / 2 or SerialMousePS / 2 or USBPS / 2Keyboard

NowThenPort

Page 79: Computer Science 1 Week 2. CSc 1, Sacramento State This Week... QBasic Programming QBasic Programming Computer Concepts Computer Concepts  Input & Output

CSc 1, Sacramento State