JK

Chapter 1 Summary: Introduction to Computers and Programming

Introduction

  • Computers are programmable and execute instructions from programs (software).

  • Programmers design, create, and test these programs.

Hardware and Software

  • Hardware: Physical components of a computer (CPU, memory, storage, input/output devices).

  • Software: Programs that control the computer.

Components of Hardware

  • CPU (Central Processing Unit): Runs programs; located on microprocessors.

  • Main Memory (RAM): Temporary, volatile storage for running programs and data.

  • Secondary Storage: Long-term data storage (disk drives, solid-state drives, flash memory).

  • Input Devices: Collect data (keyboard, mouse, etc.).

  • Output Devices: Present data (video display, printer, etc.).

Types of Software

  • Application Software: For everyday tasks (word processing, web browsing).

  • System Software: Manages computer operations.

    • Operating System: Controls hardware.

    • Utility Programs: Enhance operation/safeguard data.

    • Software Development Tools: Create/modify software.

How Computers Store Data

  • Data is stored as sequences of 0s and 1s.

  • Bit: Electrical component holding positive or negative charge.

  • Byte: 8 bits; stores a letter or small number.

  • Binary numbering system is used; position j has value 2^{j-1}.

  • Characters are converted to numeric codes (ASCII, Unicode).

  • Negative numbers use two’s complement; real numbers use floating-point notation.

  • Digital images are stored as pixels (binary numbers representing color); digital music as samples (binary numbers).

How a Program Works

  • CPU performs simple operations using machine language.

  • Program execution cycle: Fetch (instruction from memory), Decode (determine operation), Execute (perform operation).

Languages

  • Assembly Language: Uses mnemonics; translated to machine language by an assembler.

  • High-Level Language: More intuitive; doesn't require knowledge of CPU operation.

  • Keywords: Predefined words in high-level languages.

  • Operators: Perform operations on data.

  • Syntax: Rules for writing programs.

  • Statement: Individual instruction.

Compilers and Interpreters

  • Compiler: Translates high-level to machine language.

  • Interpreter: Translates and executes one instruction at a time (used by Python).

  • Source code: Statements written by programmer.

  • Syntax error: Prevents code translation.

Using Python

  • Python interpreter can be used in interactive mode (statements entered on keyboard) or script mode (statements saved in a .py file).

  • IDLE: Integrated Development Environment for writing, executing, and testing Python programs. Runs in interactive mode and has a text editor.