Chapter - 1 Notes of Tony Gaddis Python Book
Chapter - 1 Notes of Tony Gaddis Python Book
Programming
1.1 Introduction
A program is a set of instructions that a computer follows to perform a task. Programs are
commonly referred to as software. A programmer, or software developer, is a person with the
training and skills necessary to design, create, and test computer programs.
The ENIAC, which is considered by many to be the world’s first programmable electronic computer,
was built in 1945 to calculate artillery ballistic tables for the U.S. Army. This machine, which was
primarily one big CPU, was 8 feet tall, 100 feet long, and weighed 30 tons.
Today, CPUs are small chips called microprocessors. Main memory is commonly known as random-
access memory, or RAM, where a program is stored while it is running. Secondary storage is a type of
memory that can hold data for long periods of time, even when there is no power to the computer.
As far software is concerned there are two general categories of software: system software and
application software. System software include these types operating systems, utility programs and
software development tools.
In computer systems, a bit that is turned off represents the number 0, and a bit that is turned on
represents the number 1. This corresponds perfectly to the binary numbering system. Binary system
is used in case of storing numbers where for English letters ASCII, which stands for the American
Standard Code for Information Interchange. ASCII is a set of 128 numeric codes that represent the
English letters, various punctuation marks, and other characters. Unicode is an extensive encoding
scheme that is compatible with ASCII, but can also represent characters for many of the languages in
the world. Today, Unicode is quickly becoming the standard character set used in the computer
industry.
Negative numbers are encoded using a technique known as two’s complement, and real numbers
are encoded in floating-point notation.
To you and me, this is only a series of 0s and 1s. To a CPU, however, this is an instruction to perform
an operation.1 It is written in 0s and 1s because CPUs only understand instructions that are written
in machine language, and machine language instructions always have an underlying binary
structure.
When a CPU executes the instructions in a program, it is engaged in a process that is known as the
fetch-decode-execute cycle.
Assembly language was created in the early days of computing2 as an alternative to machine
language. Instead of using binary numbers for instructions, assembly language uses short words that
are known as mnemonics. Assembly language programs cannot be executed by the CPU, however.
The CPU only understands machine language, so a special program known as an assembler is used to
translate an assembly language program to a machine language program.
Assembly language is primarily a direct substitute for machine language, and like machine language,
it requires that you know a lot about the CPU. Assembly language also requires that you write a large
number of instructions for even the simplest program. Because assembly language is so close in
nature to machine language, it is referred to as a low-level language.
Python is a modern, high-level programming language that we will use in this book. In Python you
would display the message Hello world with the following instruction:
print('Hello world')
The words that make up a high-level programming language are known as keywords or reserved
words. In addition to keywords, programming languages have operators that perform various
operations on data. For example, all programming languages have math operators that perform
arithmetic.
In addition to keywords and operators, each language also has its own syntax, which is a set of rules
that must be strictly followed when writing a program. The syntax rules dictate how keywords,
operators, and various punctuation characters must be used in a program.
Depending on the language in which a program has been written, the programmer will use either a
compiler or an interpreter to make the translation. A compiler is a program that translates a high-
level language program into a separate machine language program. The Python language uses an
interpreter, which is a program that both translates and executes the instructions in a high-level
language program. The statements that a programmer writes in a high-level language are called
source code, or simply code. Typically, the programmer types a program’s code into a text editor
then saves the code in a file on the computer’s disk. Next, the programmer uses a compiler to
translate the code into a machine language program, or an interpreter to translate and execute the
code. If the code contains a syntax error, however, it cannot be translated. A syntax error is a
mistake such as a misspelled keyword, a missing punctuation character, or the incorrect use of an
operator.
Print(“Hello”)
Hello #python print function