KEMBAR78
Unit 1.1 Introduction to python programming | PPTX
Int. to Programming
(PYTHON)
Copyright © 2018 Pearson Education,
Ltd.
C H A P T E R
1
Introduction
to
Computers
and
Programmin
g
Copyright © 2018 Pearson Education,
Ltd.
Topics
Copyright © 2018 Pearson Education,
Ltd.
• Introduction
• Hardware and Software
• How Computers Store Data
• How a Program Works
• Using Python
Introduction
Copyright © 2018 Pearson Education,
Ltd.
• 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
Hardware and Software
Copyright © 2018 Pearson Education,
Ltd.
• 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
The CPU
Copyright © 2018 Pearson Education,
Ltd.
• 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
Main Memory
Copyright © 2018 Pearson Education,
Ltd.
• 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
Secondary Storage Devices
Copyright © 2018 Pearson Education,
Ltd.
• Secondary storage: can hold data for long
periods of time
• Programs normally stored here and loaded
to main memory when needed
• E.g. Hard disk
Input Devices
Copyright © 2018 Pearson Education,
Ltd.
• Input: data the computer collects from
people and other devices
• Input device: component that collects
the data
• Examples: keyboard, mouse,
touchscreen, scanner, camera
• Disk drives can be considered input devices
because they load programs into the main
memory
Output Devices
Copyright © 2018 Pearson Education,
Ltd.
• 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 USB drives can be
considered output devices because data is
sent to them to be saved
Software
Copyright © 2018 Pearson Education,
Ltd.
• 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, email,
games, and Web browsers
Software
Copyright © 2018 Pearson Education,
Ltd.
• 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
• E.g Data backup programs
How Computers Store Data
Copyright © 2018 Pearson Education,
Ltd.
• A computer’s memory is divided into
tiny storage locations known as bytes.
• 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
Storing Characters
Copyright © 2018 Pearson Education,
Ltd.
• 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
Copyright © 2018 Pearson Education,
Ltd.
• To store negative numbers and real
numbers, computers use binary
numbering and encoding schemes
How a Program Works
Copyright © 2018 Pearson Education,
Ltd.
• 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 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
How a Program Works
(cont’d.)
Copyright © 2018 Pearson Education,
Ltd.
• 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
How a Program Works
(cont’d.)
Figure 1-16 The fetch-decode-execute cycle
Copyright © 2018 Pearson Education,
Ltd.
From Machine Language to
Assembly Language
Copyright © 2018 Pearson Education,
Ltd.
• 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
High-Level Languages
Copyright © 2018 Pearson Education,
Ltd.
• 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
Key Words, Operators, and
Syntax: an Overview
Copyright © 2018 Pearson Education,
Ltd.
• Key words: predefined words used to
write program in high-level language
• Each key word has specific meaning
• Operators: perform operations on data
• Example: math operators to perform
arithmetic
• Syntax: set of rules to be followed when
writing program
Compilers and Interpreters
Copyright © 2018 Pearson Education,
Ltd.
• 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
Compilers and Interpreters
(cont’d.)
Copyright © 2018 Pearson Education,
Ltd.
• 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 (or code): statements
written by programmer
• Syntax error: prevents code from
being translated
Compilers and Interpreters
(cont’d.)
Figure 1-19 Executing a high-level program with an interpreter
Copyright © 2018 Pearson Education,
Ltd.

Unit 1.1 Introduction to python programming

  • 1.
    Int. to Programming (PYTHON) Copyright© 2018 Pearson Education, Ltd.
  • 2.
    C H AP T E R 1 Introduction to Computers and Programmin g Copyright © 2018 Pearson Education, Ltd.
  • 3.
    Topics Copyright © 2018Pearson Education, Ltd. • Introduction • Hardware and Software • How Computers Store Data • How a Program Works • Using Python
  • 4.
    Introduction Copyright © 2018Pearson Education, Ltd. • 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
  • 5.
    Hardware and Software Copyright© 2018 Pearson Education, Ltd. • 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
  • 6.
    The CPU Copyright ©2018 Pearson Education, Ltd. • 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.
    Main Memory Copyright ©2018 Pearson Education, Ltd. • 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
  • 8.
    Secondary Storage Devices Copyright© 2018 Pearson Education, Ltd. • Secondary storage: can hold data for long periods of time • Programs normally stored here and loaded to main memory when needed • E.g. Hard disk
  • 9.
    Input Devices Copyright ©2018 Pearson Education, Ltd. • Input: data the computer collects from people and other devices • Input device: component that collects the data • Examples: keyboard, mouse, touchscreen, scanner, camera • Disk drives can be considered input devices because they load programs into the main memory
  • 10.
    Output Devices Copyright ©2018 Pearson Education, Ltd. • 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 USB drives can be considered output devices because data is sent to them to be saved
  • 11.
    Software Copyright © 2018Pearson Education, Ltd. • 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, email, games, and Web browsers
  • 12.
    Software Copyright © 2018Pearson Education, Ltd. • 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 • E.g Data backup programs
  • 13.
    How Computers StoreData Copyright © 2018 Pearson Education, Ltd. • A computer’s memory is divided into tiny storage locations known as bytes. • 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
  • 14.
    Storing Characters Copyright ©2018 Pearson Education, Ltd. • 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
  • 15.
    Copyright © 2018Pearson Education, Ltd. • To store negative numbers and real numbers, computers use binary numbering and encoding schemes
  • 16.
    How a ProgramWorks Copyright © 2018 Pearson Education, Ltd. • 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 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
  • 17.
    How a ProgramWorks (cont’d.) Copyright © 2018 Pearson Education, Ltd. • 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
  • 18.
    How a ProgramWorks (cont’d.) Figure 1-16 The fetch-decode-execute cycle Copyright © 2018 Pearson Education, Ltd.
  • 19.
    From Machine Languageto Assembly Language Copyright © 2018 Pearson Education, Ltd. • 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
  • 20.
    High-Level Languages Copyright ©2018 Pearson Education, Ltd. • 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
  • 21.
    Key Words, Operators,and Syntax: an Overview Copyright © 2018 Pearson Education, Ltd. • Key words: predefined words used to write program in high-level language • Each key word has specific meaning • Operators: perform operations on data • Example: math operators to perform arithmetic • Syntax: set of rules to be followed when writing program
  • 22.
    Compilers and Interpreters Copyright© 2018 Pearson Education, Ltd. • 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
  • 23.
    Compilers and Interpreters (cont’d.) Copyright© 2018 Pearson Education, Ltd. • 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 (or code): statements written by programmer • Syntax error: prevents code from being translated
  • 24.
    Compilers and Interpreters (cont’d.) Figure1-19 Executing a high-level program with an interpreter Copyright © 2018 Pearson Education, Ltd.