Introduction To Computers and Programming - Chapter1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

Introduction to Computers and

Programming

Hong Sun
COSC 1436 Spring 2017
Jan 23 , 2017
Introduction
• What is a program
– Software: Controls everything the computer does
• What is hardware
– The physical devices that a computer is made of are referred to as hardware
• Five major components:
• CPU – the central processing unit
– Microprocessors; the part of a computer that actually runs programs.
• Main memory
– Random-access memory(RAM) - Computer’s work area.
• Secondary storage devices
– A type of memory that can hold data for long periods of time.
• Input devices
– Any data the computer collets from people and from other devices The component that collects
data and sends it to the computer is called input device.
• Output devices
– Any data the computer produces for people or for other devices. The component that produces
output data is called output devices.
How Computers Store Data
• All data that is stored in a computer is
converted to sequences of 0s and 1s
– Bytes – memory is divided into tiny storage
locations
– Bits – binary digit
– Store numbers, Characters….images

1 1 1 1 1 1 0 0, 0 1 0 1 1 1 1 1
How Computers Store Data
(the values of binary digits as power of
2)
How Computers Store Data

• When a character is sorted in memory, it is first


converted to a numeric code. The most important of
those coding schema is ASCII.

• ASCII (American Standard Code for Information


Interchange) is the most common format for text files in
computers and on the Internet. In an ASCII file, each
alphabetic, numeric, or special character is represented
with a 7-bit binary number (a string of seven 0s or 1s).
128 possible characters are defined.
How Computers Store Data

• Computers are able to store negative and real number in


memory using encoding schema. Negative numbers are
encoded in two’s complement, and real numbers are
encoded in floating-point notation

• Images are exposed of tiny dots of color known as pixels


How a Program Works
• Fetch
• The first step of the cycle is fetch, or read, the next instruction
from memory into the CPU
• Decode
• A machine language instruction is a binary number that
represents a command that tells the CPU to perform an
operation. In this step the CPU decodes the instruction that
was just fetched from memory, to determine which operation
it should perform.
• Execute
• The last step in the cycle is to execute, or perform, the
operation.
How a Program Works
• Compilers and Interpreters
• A compiler is a program that translates a high-level language program
into a separate machine language program. The machine language
program can then be executed any time it is needed.

• A interpreter is a program that both translates and executes the


instructions in a high-level language program. As the interpreter reads
each individual instruction in the program, it converts it to machine
language instructions and then immediately executes them. Because
interpreters combine translation and execution, they typically do not
create separate machine language programs.

• Python is interpreter language.


Python
• High level languages
– Created in 1950s. A high-level language allows you
to create powerful and complex programs without
knowing how the CPU works and without writing
large numbers of low-level instructions. In
addition, most high-level languages use words
that are easy to understand.
– List of high-level languages: Ada, Basic, Fortran,
Cobol, Pascal, C and C++, C#, Java, JavaScript,
Python, Ruby, Visual Basic
Python basic
• Python is an easy to learn, powerful programming language. It has
efficient high-level data structures and a simple but effective
approach to object-oriented programming. Python’s elegant syntax
and dynamic typing, together with its interpreted nature, make it
an ideal language for scripting and rapid application development in
many areas on most platforms.
• The Python interpreter and the extensive standard library are freely
available in source or binary form for all major platforms from the
Python Web site, https://www.python.org/, and may be freely
distributed. The same site also contains distributions of and
pointers to many free third party Python modules, programs and
tools, and additional documentation.
• The Python interpreter is easily extended with new functions and
data types implemented in C or C++ (or other languages callable
from C). Python is also suitable as an extension language for
customizable applications.
Python and GIS
• Very popular with Geospatial professionals working
in the ESRI environment and is considered as the
primary scripting language for ArcGIS.

• The ArcPy site package provides access to the


geoprocessing tools found in ArcGIS for Desktop.
Using it can be a challenge if you are unfamiliar with
Python, but with some basic knowledge, you can
start using it to make your ArcGIS work flows faster
and easier.
Using Python
• Installing Python:
• https://www.python.org/downloads/

• Interactive Mode
• Script Mode
• IDLE Programming Environment
• The Python Key Words
• p17
Lab exercise and Assignment
• Installing Python on your computer
• Book for download
http://file.allitebooks.com/20151103/Starting%20Out%20with%20Pyt
hon,%203rd%20edition.pdf

• Learning Web Link:


https://learning.hccs.edu/faculty/hong.sun/cosc1436-1

• Reading Assignments:
• Review Questions
– p24 –p27
– Exercises 1-6
P28 – 29

You might also like