Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 1 Introduction to Computers and Programming.

Slides:



Advertisements
Similar presentations
COSC 120 Computer Programming
Advertisements

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Sixth Edition by Tony Gaddis, Judy Walters,
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
CS 0008 Day 2 1. Today Hardware and Software How computers store data How a program works Operators, types, input Print function Running the debugger.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
CS102 Introduction to Computer Programming
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Why Program? Computer – programmable machine designed to follow instructions Program – instructions in computer memory to make it do something Programmer.
Chapter Introduction to Computers and Programming 1.
Introduction to Programming Dr Masitah Ghazali Programming Techniques I SCJ1013.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Topics Introduction Hardware and Software How Computers Store Data
© Paradigm Publishing Inc. 2-1 Chapter 2 Input and Processing.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 1 Introduction to Computers and Programming Starting Out with.
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming 1.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Copyright © 2012 Pearson Education, Inc. Chapter 1 Introduction to Computing and Programming.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
An Introduction to Computers August 12, 2008 Mrs. C. Furman.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Introduction to Programming Peggy Batchelor.
© Paradigm Publishing Inc. 2-1 Chapter 2 Input and Processing.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Introduction Lecture 01.
Introduction to Computer Systems and the Java Programming Language.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 1 Introduction.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
Intro to Computers Computer Applications. What is a Computer? Initially the term computer referred to an individual whose job it was to perform mathematical.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Programming
CSC 1010 Programming for All Lecture 2 Introduction to Python Some material based on material from Marty Stepp, Instructor, University of Washington.
Computer and Programming. Computer Basics: Outline Hardware and Memory Programs Programming Languages and Compilers.
Copyright © 2016 Pearson Education, Inc., Hoboken NJ CHAPTER 1 Introduction to Computers and Programming.
Brief Version of Starting Out with C++ Chapter 1 Introduction to Computers and Programming.
1. COMPUTERS AND PROGRAMS Rocky K. C. Chang September 6, 2015 (Adapted from John Zelle’s slides)
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming Dr. Halla Abdel Hameed.
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. Introduction to Computers and Computing.
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Programming
BASIC PROGRAMMING C SCP1103 (02)
Chapter 1: An Overview of Computers and Programming Languages
Topics Introduction Hardware and Software How Computers Store Data
BASIC PROGRAMMING C SCP1103 (02)
Chapter 1: Introduction to Computers and Programming
Topics Introduction to Repetition Structures
Chapter 1: An Overview of Computers and Programming Languages
Chapter 1 Introduction to Computers and Programming
Chapter 1: Introduction to Computers and Programming
People use computers at…
Chapter 1: Introduction to Computers and Programming
CS190/295 Programming in Python for Life Sciences: Lecture 1
Topics Introduction Hardware and Software How Computers Store Data
Topics Introduction Hardware and Software How Computers Store Data
Plan Attendance Files Posted on Campus Cruiser Homework Reminder
How Computers Store Data
General Computer Science for Engineers CISC 106 Lecture 03
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 1 Introduction to Computers and Programming

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Topics Introduction Hardware and Software How Computers Store Data How a Program Works Using Python 2

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Introduction Computers can be programmed –Designed to do any job that a program tells them to Program: set of instructions that a computer follows to perform a task –Commonly referred to as Software Programmer: person who can design, create, and test computer programs –Also known as software developer 3

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Hardware and Software Hardware: The physical devices that make up a computer –Computer is a system composed of several components that all work together Typical major components: –Central processing unit –Main memory –Secondary storage devices –Input and output devices 5

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

The CPU Central processing unit (CPU): the part of the computer that actually runs programs –Most important component –Without it, cannot run software –Used to be a huge device Microprocessors: CPUs located on small chips 7

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Main Memory Main memory: where computer stores a program while program is running, and data used by the program Known as Random Access Memory or RAM –CPU is able to quickly access data in RAM –Volatile memory used for temporary storage while program is running –Contents are erased when computer is off 10

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Secondary Storage Devices Secondary storage: can hold data for long periods of time –Programs normally stored here and loaded to main memory when needed Types of secondary memory –Disk drive: magnetically encodes data onto a circular disk –Flash memory: portable, no physical disk –Optical devices: data encoded optically 12

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Input Devices Input: data the computer collects from people and other devices Input device: component that collects the data –Examples: keyboard, mouse, scanner, camera –Disk drives can be considered input devices because they load programs into the main memory 13

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Output Devices Output: data produced by the computer for other people or devices –Can be text, image, audio, or bit stream Output device: formats and presents output –Examples: video display, printer –Disk drives and CD recorders can be considered output devices because data is sent to them to be saved 14

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Software Everything the computer does is controlled by software –General categories: Application software System software Application software: programs that make computer useful for every day tasks –Examples: word processing, , games, and Web browsers 15

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Software (cont’d.) System software: programs that control and manage basic operations of a computer –Operating system: controls operations of hardware components –Utility Program: performs specific task to enhance computer operation or safeguard data –Software development tools: used to create, modify, and test software programs 16

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

How Computers Store Data All data in a computer is stored in sequences of 0s and 1s Byte: just enough memory to store letter or small number –Divided into eight bits –Bit: electrical component that can hold positive or negative charge, like on/off switch –The on/off pattern of bits in a byte represents data stored in the byte Figure 1-7 Think of a byte as eight switches 18

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Storing Numbers Bit represents two values, 0 and 1 Computers use binary numbering system –Position of digit j is assigned the value 2 j-1 –To determine value of binary number sum position values of the 1s Byte size limits are 0 and 255 –0 = all bits off; 255 = all bits on –To store larger number, use several bytes 20

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

How Computers Store Data Storing Numbers For example: Figure 1-11 Determining the value of Figure 1-12 The bit pattern for

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley How Computers Store Data Storing Numbers For example: Two bytes are used for larger numbers; maximum value is Figure 1-13 Two bytes used for a large number 23

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Storing Characters Data stored in computer must be stored as binary number Characters are converted to numeric code, numeric code stored in memory –Most important coding scheme is ASCII ASCII is limited: defines codes for only 128 characters –Unicode coding scheme becoming standard Compatible with ASCII Can represent characters for other languages 24

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Storing Characters For example: Figure 1-14 The letter A is stored in memory as the number 65 25

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Advanced Number Storage To store negative numbers and real numbers, computers use binary numbering and encoding schemes –Negative numbers encoded using two’s complement –Real numbers encoded using floating-point notation 26

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Other Types of Data Digital: describes any device that stores data as binary numbers Digital images are composed of pixels –To store images, each pixel is converted to a binary number representing the pixel’s color Digital music is composed of sections called samples –To store music, each sample is converted to a binary number 27

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

How a Program Works CPU designed to perform simple operations on pieces of data –Examples: reading data, adding, subtracting, multiplying, and dividing numbers –Understands instructions written in machine language (0’s and 1’s only) and included in its instruction set Each brand of CPU has its own instruction set To carry out meaningful calculation, CPU must perform many operations 29

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley How a Program Works (cont’d.) Program must be copied from secondary memory to RAM each time CPU executes it CPU executes program in cycle: –Fetch: read the next instruction from memory into CPU –Decode: CPU decodes fetched instruction to determine which operation to perform –Execute: perform the operation 30

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley How a Program Works (cont’d.) Figure 1-17 The fetch-decode-execute cycle 31

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley From Machine Language to Assembly Language Impractical for people to write in machine language Assembly language: uses short words (mnemonics) for instructions instead of binary numbers –Easier for programmers to work with Assembler: translates assembly language to machine language for execution by CPU 32

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley From Machine Language to Assembly Language Figure 1-18 An assembler translates an assembly language program to a machine language program 33

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley High-Level Languages Low-level language: close in nature to machine language –Example: assembly language High-Level language: allows simple creation of powerful and complex programs –No need to know how CPU works or write large number of instructions –More intuitive to understand –See list on page 17 in textbook 34

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Key Words, Operators, and Syntax: an Overview Key words: predefined words used to write program in high-level language –Each key word has specific meaning 36

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Key Words, Operators, and Syntax: an Overview Operators: perform operations on data –Example: math operators to perform arithmetic Syntax: set of rules to be followed when writing program –Dictate how key words, operators, and punctuation must be used in a program Statement: individual instruction used in high-level language 37

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Compilers and Interpreters Programs written in high-level languages must be translated into machine language to be executed Compiler: translates high-level language program into separate machine language program –Machine language program can be executed at any time 38

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Compilers and Interpreters Figure 1-19 Compiling a high-level program and executing it 39

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Compilers and Interpreters (cont’d.) Interpreter: translates and executes instructions in high-level language program –Used by Python language –Interprets one instruction at a time –No separate machine language program Source code: statements written by programmer –Syntax error: prevents code from being translated 40

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Compilers and Interpreters (cont’d.) Figure 1-20: Executing a high-level program with an interpreter 41

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Using Python Python must be installed and configured prior to use –One of the items installed is the Python interpreter Python interpreter can be used in two modes: –Interactive mode: enter statements on keyboard and execute immediately –Script mode: save statements in Python script as a file which can be executed later 42

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Interactive Mode When you start Python in interactive mode, you will see a prompt –Indicates the interpreter is waiting for a Python statement to be typed –Prompt reappears after previous statement is executed –Error message displayed If you incorrectly type a statement Good way to learn new parts of Python 43

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Interactive Mode Invoke Python interpreter through Windows or command line >>> is the prompt that indicates the interpreter is waiting for a Python statement >>> print(‘Python programming is fun!’) Python programming is fun! >>> Statements typed in interactive mode are not saved as a program 44

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Writing Python Programs and Running Them in Script Mode To have a program use script mode –Save a set of Python statements in a file –The filename should have the.py extension –To run the file, or script, type python filename at the operating system command line 45

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley The IDLE Programming Environment IDLE (Integrated Development Program): single program that provides tools to write, execute and test a program –Automatically installed when Python language is installed –Runs in interactive mode –Has built-in text editor with features designed to help write Python programs Described in detail in Appendix B 46

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Homework 1 Homework 1 assigned now (Class Session 1) View “Creating Windows Compressed Folder” video in the Homework 1 folder Homework 1 due in one week (Class Session 3) Submit Homework 1 to the Homework 1 drop box 48

Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Summary This chapter covered: –Main hardware components of the computer –Types of software –How data is stored in a computer –Basic CPU operations and machine language –Fetch-decode-execute cycle –Complex languages and their translation to machine code –Installing Python and the Python interpreter modes 49