0% found this document useful (0 votes)
18 views16 pages

Cpen Reviewer

The document provides an overview of computer programming, including definitions of software and hardware, the roles of CPUs, main memory, secondary storage, input and output devices, and how data is stored and processed. It outlines the program development cycle, emphasizing the importance of understanding the problem, planning logic, coding, testing, and maintaining programs. Additionally, it introduces Python as a high-level programming language, highlighting its features, popularity, and applications.

Uploaded by

johnred.catamio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views16 pages

Cpen Reviewer

The document provides an overview of computer programming, including definitions of software and hardware, the roles of CPUs, main memory, secondary storage, input and output devices, and how data is stored and processed. It outlines the program development cycle, emphasizing the importance of understanding the problem, planning logic, coding, testing, and maintaining programs. Additionally, it introduces Python as a high-level programming language, highlighting its features, popularity, and applications.

Uploaded by

johnred.catamio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

INTRODUCTION

• A program is a set of instructions that a computer follows to perform a task.

• Programs are commonly referred to as software.

• Software is essential to a computer because without software, a computer can do nothing.

• A programmer, or software developer, is a person with the training and skills necessary to
design, create, and test computer programs.

HARDWARE
• The term hardware refers to all of the physical devices, or components, that a computer is
made of.
• A computer is not one single device, but a system of devices that all work together.
• A typical computer system consists of the following major components:
•The central processing unit (CPU)
•Main memory
•Secondary storage devices
•Input devices
•Output devices

CPU
• The central processing unit, or CPU, is the part of a computer that actually runs programs.
• The CPU is the most important component in a computer because without it, the computer
could not run software.
• In the earliest computers, CPUs were huge devices made of electrical and mechanical
components such as vacuum tubes and switches.
● The ENIAC (Electrical Numerical Integrator and Computer), considered by many to
be the world’s first programmable electronic computer. This machine, which was
primarily one big CPU, was 8 feet tall, 100 feet long, and weighed 30 tons.
•Today, CPUs are small chips known as microprocessors. Smaller than the old
electro-mechanical CPUs in early computers; microprocessors are also much more powerful

MAIN MEMORY
• Main memory is where the computer stores a program while the program is running, as
well as the data that the program is working with.
• Main memory is commonly known as random-access memory, or RAM.
• RAM is usually a volatile type of memory that is used only for temporary storage while a
program is running.
• When the computer is turned off, the contents of RAM are erased.

SECONDARY STORAGE DEVICES


• 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.
• Programs are normally stored in secondary memory and loaded into main memory as
needed.
• The most common type of secondary storage device is the disk drive.
• A disk drive stores data by magnetically encoding it onto a circular disk.
• External disk drives can be used to create backup copies of important data or to move data
to another computer.
• A floppy disk drive records data onto a small floppy disk, which can be removed from the
drive.
• Floppy disks hold only a small amount of data, are slow to access data, and are sometimes
unreliable.
• USB drives are small devices that plug into the computer’s USB (universal serial bus) port,
and appear to the system as a disk drive.
• They store data in a special type of memory known as flash memory.
• USB drives, which are also known as memory sticks and flash drives, are inexpensive,
reliable, and small enough to be carried in your pocket.
• Optical devices such as the CD (compact disc) and the DVD (digital versatile disc) are also
popular for data storage.
• CD and DVD drives use a laser to detect the pits on disc surface and thus read the
encoded data.
• Optical discs hold large amounts of data, and because recordable CD and DVD drives are
now commonplace, they are good mediums for creating backup copies of data.

INPUT DEVICES
• Input is any data the computer collects from people and from other devices.
• The component that collects the data and sends it to the computer is called an input
device.
• Common input devices are the keyboard, mouse, scanner, microphone, and digital camera.

OUTPUT DEVICES
• Output is any data the computer produces for people or for other devices.
• The data is sent to an output device,which formats and presents it.
• Common output devices are video displays and printers.

Program – Microsoft Office, Adobe Software, Notepad

HOW COMPUTER STORE DATA?


• All data that is stored in a computer is converted to sequences of 0s and 1s.
• A computer’s memory is divided into tiny storage locations known as bytes.
• Each byte is divided into eight smaller storage locations known as bits.
• The term bit stands for binary digit.
One byte is only enough memory to store a letter of the alphabet or a small number.
STORING NUMBERS
•A bit that is turned off represents the number 0 and a bit that is turned on represents the
number 1.
• The position of each digit in a binary number has a value assigned to it.

STORING CHARACTERS
• Any piece of data that is stored in a computer’s memory must be stored as a binary
number That includes characters, such as letters and punctuation marks.
• When a character is stored in memory, it is first converted to a numeric code then numeric
code is then stored in memory as a binary number.
• The most important of these coding schemes is 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, and can also
represent the characters of many of the world’s languages.

Negative numbers are encoded using a technique known as two’s complement


Real numbers are encoded in floating-point notation
Other types of data:
These images are composed of tiny dots of color known as pixels.

HOW A PROGRAM WORKS?


• A computer’s CPU can only understand instructions that are written in machine language.
But people find it very difficult to write entire programs in machine language, programming
languages have been invented.
• CPU is the most important component in a computer because it is the part of the computer
that runs programs. (CPU is called “computer’s brain” and described as being smart)
• CPU performs simple operations on pieces of data.
• A program is nothing more than a list of instructions that cause the CPU to perform
operations.
• The entire set of instructions that a CPU can execute is known as the CPU’s instruction set.
Although a program can be stored on a secondary storage device such as a disk drive, it has
to be copied into main memory, or RAM, each time the CPU executes it. For example,
suppose you have a word processing program on your computer’s disk.

FETCH-DECODE-EXECUTE CYCLE
1.Fetch or read instruction in the program from memory into the CPU.
2.Decode the instruction to determine which operation to perform.
3.Execute or perform the operation.

FROM MACHINE TO ASSEMBLY LANGUAGE


• Although a computer’s CPU only understands machine language, it is impractical for
people to write programs in machine language.
• Assembly language was created in the early days of computing as an alternative to
machine language.
• Assembly language uses short words that are known as mnemonics.
• A special program known as an assembler is used to translate an assembly language
program to a machine language program.
Mnemonic (works of the CPU)
Add – add value
Sub – subtract
Mult – multiply
Div – divide
Stop – stop execution
MoveR – move register
moveM –move memory
Call – call routine

HIGH LEVEL LANGUAGE


• Assembly language is so close in nature to machine language, it is referred to as a
low-level language.
• 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.
• Programming Languages: Ada, C#, BASIC, Java, FORTRAN, Java Script, COBOL,
PythoN, Pascal, Ruby, C and C++, Visual Basic
Each high-level language has its own set of words that the programmer must learn in order
to use the language. The words that make up a high-level programming language are known
as key words or reserved words. Each key word has a specific meaning, and cannot be used
for any other purpose.
PRINT OR DISPLAY, INPUT, IF…THEN ELSE, ELSEIF, DO…WHILE, DOUBLE, FLOAT
AND INTEGER, CONST AND CHAR, SWITCH, CASE, BREAK AND CONTINUE
● programming languages have operators that perform various operations on data.
Each language also has its own syntax, which is a set of rules that must be strictly
followed when writing a program. The individual instructions that you use to write a
program in a high-level programming language are called statements. A
programming statement can consist of key words, operators, punctuation, and other
allowable programming elements, arranged in the proper sequence to perform an
operation.

COMPILER VS INTERPRETER VS ASSEMBLER


COMPILER INTERPRETER ASSEMBLER

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. Example: C and C++
Interpreter: Ruby, Python
Error detection: Compiler (first error) while interpreter (list of error)

SOFTWARE
• Programs generally fall into one of two categories:
>System software control or enhance the operation of a computer.
>Application software makes a computer useful for everyday tasks

SYSTEM SOFTWARE
● System software typically includes the following types of programs:
● Operating System controls internal operations of the computer’s hardware,
manages all devices connected to the computer, allows data to be saved to and
retrieved from storage devices, and allows other program to run on the computer.
(i.e. Windows, IOS, Mac OS, Linux)
● Utiliy Programs performs a specialized task that enhances the computer’s operation
or safeguards data. (i.e. virus scanners, file compression programs and data
back-up)
● Software Development Tools are the programs that programmers use to create,
modify, and test software. (i.e. assemblers, compilers, and intepreters)

LESSON 2

PROGRAM DEVELOPMENT CYCLE AND PROBLEM-SOLVING TECHNIQUES

Program Development Life Cycle (PDLC) is a systematic way of developing quality


software.

● It provides an organized plan for breaking down the task of program development
into manageable chunks, each of which must be completed before moving on to the
next phase.
● The Program Development Life Cycle (PDLC) is like a step-by-step guide that
helps developers create quality software efficiently. Think of it like building a
house—you need a plan to ensure everything gets done in the right order and is built
properly.
● PDLC breaks down software development into smaller, manageable parts or phases.
Each phase focuses on a specific part of the process, and you can’t move to the next
phase until the current one is complete. This approach ensures that the software is
well-designed, free of major errors, and meets the user’s needs.

PROGRAM DEVELOPMENT CYCLE

1.Understand the problem

● Professional computer programmers write programs to satisfy the needs of others,


called users or end users.
● When you plan a program, you think of the output first. After you understand what
the desired result is, you can plan what to input and process to achieve it.
● Documentation consists of all the supporting paperwork for a program; it might
include items such as original requests for the program from users, sample output,
and descriptions of the data items available for input.

2.Plan the logic


● During this phase of the process, the programmer plans the steps of the program,
deciding what steps to include and how to order them.
● The two most common planning tools are flowcharts and pseudocode.
● The process of walking through a program’s logic on paper before you actually write
the program is called desk-checking.

•ALGORITHM- An algorithm is a sequence of steps to solve a particular problem or an


ordered set of unambiguous steps that produces a result and terminates in a finite time.

•The word “algorithm” relates to the name of the mathematician Al-Khwarizmi, which means
a procedure or a technique.

•Algorithm has the following characteristics:

1. Input: An algorithm may or may not require input.


2. Output: Each algorithm is expected to produce at least one result.
3. Definiteness: Each instruction must be clear and unambiguous.
4. Finiteness: If the instructions of an algorithm are executed, the algorithm should
terminate after a finite number of steps.

3.Code the program

● Programmers choose particular languages because some have built-in capabilities


that make them more efficient than others at handling certain types of operations.
● Only after choosing a language must the programmer be concerned with proper
punctuation and the correct spelling of commands—in other words, using the correct
syntax.

4. Use software (compiler or interpreter) to translate the program into machine language

● Each computer knows only one language: its machine language, which consists of
1s and 0s.
● Syntax error is a misuse of a language’s grammar rules.
● CREATING THE EXECUTABLE PROGRAM
When writing a program, a programmer might need to recompile the code several times. An
executable program is created only when the code is free of syntax errors. When you run an
executable program, it typically also might require input data. Figure 1-2 shows a diagram of
this entire process.

5.Test the program

● A logical error results when you use a syntactically correct statement but use the
wrong one for the current context.
● Once a program is free of syntax errors, the programmer can test it—that is, execute
it with some sample data to see whether the results are logically correct.
● A program that is free of syntax errors is not necessarily free of logical errors. A
logical error results when you use a syntactically correct statement but use the wrong
one for the current context.
● The process of finding and correcting program errors is called debugging.

6.Put the program into production

● Once the program is tested adequately, it is ready for the organization to use.
● The process might take months if the program will be run on a regular basis, or if it is
one of a large system of programs being developed.
● Conversion is the entire set of actions an organization must take to switch over to
using a new program or set of programs, can sometimes take months or years to
accomplish.

7.Maintain the program

● After programs are put into production, making necessary changes is called
maintenance.When you make changes to existing programs, you repeat the
development cycle.

Using Pseudocode Statements and Flowchart Symbols


1. PSEUDOCODE
● An English-like representation of the logical steps it takes to solve a problem.
● Pseudo is a prefix that means “false,” and to code a program means to put it in a
programming language; therefore, pseudocode simply means “false code.”
WRITING PSEUDOCODE

Using pseudocode involves writing down all the steps


you will use in a program.

Pseudocode is fairly flexible because it is a planning


tool, and not the final product.

2. FLOWCHART

A pictorial representation of the same thing.

DRAWING FLOWCHARTS
● Flowcharts allow programmers to visualize
more easily how the program statements will
connect.
● Flowcharts are an excellent tool to help
them visualize how the statements in a program are
interrelated.
● INPUT SYMBOL - •Indicates an input
operation. You write an input statement in English
inside the parallelogram.
● PROCESSING SYMBOL- •Rectangle is
used as the processing symbol. It contains a
processing statement. Arithmetic operation
statements are examples of processing

● OUTPUT SYMBOL- •Output statement, use the same symbol as for input
statements.

● Use arrows, or flowlines, to connect the steps and show the correct sequence of
these statements.
● Most of a flowchart should read from top to bottom or from left to right on a page.
● Terminal symbols, or start/stop symbols are used in the beginning and end of the
flowchart.
● You represent a decision in a flowchart by drawing a decision symbol, which is
shaped like a diamond.
● The diamond usually contains a question, the answer to which is one of two mutually
exclusive options—often yes or no.

FLOWCHART PSEUDOCODE

LESSON 3: INTRODUCTION TO PYTHON


● Python is a general purpose, high level, interpreted language with easy syntax and
dynamic semantics
● Created by Guido Van Rossum in 1989

WHY PYTHON POPULAR?


● Easy - Python is language preferred by beginners and pro like
● Free – Python is an open-source language which makes it free for everyone to use
● Applications – Python can be used for desktop, web, mobile application
development
● Library and Support – Python has great community who constantly make libraries
and help those in need

FEATURES OF PYTHON: Simplicity, open source, portability, embeddable & extensible,


interpreted, huge libraries, object orientation

USES OF PYTHON
● Better search results are provided based on ranking of the websites and much more
● The Server and Client applications are coded using Python
● Machine learning is used to cluster users based on their interest on shows and retain
them for longer
● Cyber-security analysis and other encryption and decryption work is done using
Python
● Transfer of files between peer-to-peer which started out as a normal Python file
● Scientific calculations are computed using Python

IDLE
● Simple integrated development environment (IDE)
● Python’s built-in Integrated Development and Learning Environment
● Allows to type program and run

FIRST PROGRAM
► Step 1: Start IDLE and open new window. Type:
► Step 2: Press F5 or click Run and Save. Append
.py to the filename.

Input: ask the user to type something in


String: prompt that user sees
Print: print the output

SECOND PROGRAM
Here is a program that computes the average of two numbers that user enters:

TYPING THINGS IN:


● Case: To Python, print, Print, and PRINT are all different things. For now, stick with
lowercase as most Python statements are in lowercase.
● Spaces: Spaces matter at the beginning of lines, but not elsewhere. For example,
the code below will not work.

● Indentation – To python, some statements ending with : required indentation.

GETTING INPUT
● The input function is a simple way for your program to get information from people
using your program.

● The basic structure is

PRINTING
● The print function requires parentheses

● To print several things at once, separate them by commas

QUOTATION IN PYTHON
● Python accepts single (‘), double (“) and triple (“““) quotes to denote string
● Quote starts and ends the string
● Triple quotes – span the string across multiple lines

COMMENTS IN PYTHON
● hash (#) – place at the beginning of a comment
● Comment – set as mark and Python ignores these

OPTIONAL ARGUMENTS
sep – short for separator, change space to any symbol

end – advanced to the next line

VARIABLES
● Variable remembers the value of certain data
● Variable names can contain letters, numbers, and the underscore
● Variable names cannot contain spaces
● Variable names cannot start with a number
● Case matters – temp and Temp are different

LESSON 4: PYTHON NUMBERS

INTEGERS AND DECIMAL NO.


Python supports different types of numbers:
Integers (int): Whole numbers without a decimal. Example: 10, -3, 0
Floating-point numbers (float): Numbers with a decimal part. Example: 3.14, -0.99
Complex numbers (complex): Numbers with a real and imaginary part, written as 𝑥+𝑦𝑗, where
𝑗 represents the square root of -1. Example: 2 + 3j

MATH OPERATORS AND THEIR USES


A complex number - ordered pair of real floating-point numbers denoted by x + yj, where x
and y are real numbers and j is the imaginary unit.

COMPARISON OPERATORS LOGICAL OPERATORS

MEMBERSHIP OPERATORS ORDER OF OPERATORS- python


follows
pemdas

RANDOM MODULE- The random module allows you to generate random values, which is
helpful in many programming contexts.
MATH MODULE AND FUNCTIONS

HELP ON A SPECIFIC FUNCTION OR GROUP

EXAMPLES
Write a program that: calculate and display the square root of 16; calculate and display the
sine of 90 degrees; display the value of pi
ASCII CODE TABLE

You might also like