Вы находитесь на странице: 1из 5

Programming Language

A program is a sequence of instructions expressed in standard form that specifies how to


perform a computation which can be mathematical or symbolic computation.

A programming language is a standardized communication technique to express


instruction/computation to a form understood by the computer. It can also be defined as a
tool that enables a programmer to precisely specify what data a computer will act upon, how
these data will be stored/transmitted, and precisely what actions to take under various
circumstances.

Python is one example of a programming language among thousands available in the


computing world. It is a general-purpose language, which means you can build almost
anything. But it is great for backend web development, data analysis, artificial intelligence,
and scientific computing.

Java, another programming language, considered as the most popular is also a general-
purpose language, which is very good in the area of client-server web applications and mobile
applications.

The Problem-solving Process

Computer programming is generally known as development of software or application


programs. The development of application programs requires a great deal of skill in problem
solving. Problem solving is a systematic approach which involves the following steps:
1. Formulating the problem.
2. Creatively think about solutions.
3. Expressing the solution clearly and accurately.
4. Testing the solution.

Formulating the problem involves clearly defining the problem in terms of its input and output
requirements. Every computing problem always has inputs, the computation applied to
manipulate the input to come up with the desired output.

The creative solution in programming is called algorithm which is usually presented initially
as flowchart or pseudo-code. An algorithm is a general process for solving a specific computing
problem – a step by step solution to a problem.

An algorithm presented as flowchart is a diagram containing different symbols and showing


the sequence of steps to take to solve a problem. Each symbol in the flowchart represents a
specific function or action. A pseudo-code on the other hand, is a sequence of statement to
solve a computing problem.

Expressing the solution in a clear and accurate manner is done through the use of formal
notation or programming language. Writing solutions in a specific programming language
requires knowledge of that language: its syntax and semantics.

Classification of Programming Languages

There are hundreds of programming languages available to write application programs. These
programming languages can be classified into two: Low-level languages and high-level
languages.

1. Low-level languages are those computer programs written in the native language of the
computer which can be directly executed by the processor.
a. Machine-level language (Machine Code) – the lowest level of programming
languages which can be directly executed by the computer’s processor without
undergoing translation. It is written entirely in numbers.
b. Assembly language – the next level of programming language but still considered
as low-level. It uses mnemonics or English words to represent each machine code.
The assembly code has to be translated to machine code prior to the processor’s
execution.

2. High-level language. This is a class of programming languages which closely resembles


the English Language making it easier for programmers to understand and use. But
codes in high-level languages have to be translated to machine-level language so that
the computer can execute it. High-level languages have enormous advantages over low-
level languages. First, they are much easier to program, takes less time to write
programs and they are shorter and easier to read. Furthermore, high-level languages
are portable, which means that they can run in different platforms.

Classification of Program Translator

When programmers utilize high-level languages to write an application program, the


program has to be translated to machine-level language. There are two classifications of
programs in terms of how they translate codes to machine level: Interpreter and Compiler.

1. Interpreters processes programs one line at a time, alternately reading lines and
performing computations.

2. Compilers processes programs by translating the entire program first before executing
the code and performing computations. As a result of translating the entire program, a
file called the object code is created containing the machine-level codes.

Classification of Coding Organization

Structured Programming. This is a disciplined approach to the creation of programs that is


clear, demonstrably correct and easy to modify. In this programming approach, programmers
are focused on writing functions. A function is a section of organized code that performs a
specific task. Programs developed using this approach are therefore made up of these pieces
of codes.

Object-oriented Programming (OOP). This programming approach focuses on object


technology. OOP reflects the way human beings perceive the world, that is, a world made of
objects. And these objects are characterized by their properties (attributes) and behaviors
(actions). Programmers no longer focus on writing functions but on writing object (class)
definitions. A class specifies the general format of its objects – the properties and actions
available to an object.

Basic Elements of Programming Languages

Various programming languages differ in their constructs or structures. However, there


are some details which are common to all programming languages. These are called elements
of programming languages which are described below.
1. Input. This refers to data manipulated by the program which may come from the
keyboard, file or other devices.
2. Output. This refers to data displayed on the screen, sent to a file, printer or network.
3. Operation. This refers to computations which can be mathematical such as solving a
system of equations or finding the roots of a polynomial, or symbolic computation such
as searching and replacing text in a document.
4. Sequence. This refers to the inherent flow of execution of the codes including the
possible path of execution.
5. Condition/selection. This allows the program to check for a certain condition and
execute the appropriate sequence of statements or codes.
6. Repetition/iteration/loop. This allows some section of a program to be repeated for a
predefined number of times or repeating that section of code until some conditions or
criteria are met.

Basic Program Algorithm

In programming, there is always an algorithm followed to solve a computing problem.


In highly specialized problems, there are various algorithms employed for scientific purposes.
However in this course, the basic algorithm we follow is input – process – output or I-P-O.

INPUT

PROCESS

OUTPUT

All of the problem you will encounter in this course follow this basic algorithm. Which means
that there has to be inputs whether from keyboard, from a file or embedded data; followed by
a set of process or operation which could be mathematical or symbolic; and lastly is the output,
which shows results of the operation.

Algorithm – logical procedure or set of steps to be followed to arrive at a solution to a


problem.

Ex. Recipe in a cookbook, Choreography of a dance, Word problems in math

Pseudocode – an algorithm in English statements in an outline form. This is used to


conceptualize the flow of the program before coding it in a form of programming language.

Ex. Pseudocode for getting the perimeter of a rectangle


Step 1: Measure the width and the length of the rectangle.
Step 2: Double the measure of the length and width of the rectangle.
Step 3: Add the sum to get the total. The total is the perimeter of the rectangle.

Flowchart – The graphical representation of an algorithm. Flowchart is the pictorial


description of sequenced activities and logic to be performed by the computer for carrying out
data processing. It uses special symbols, which represent a specific function.

Flowcharts are used by programmers before the actual start of any programming activity.
Flowchart is otherwise known as Data Flow Diagram.

Advantages of Flowchart
1. The flow of the program is easily understood.
2. It determines the validity of the processes involved in the program.
3. Debugging or correcting of errors becomes less complicated.
4. It produces effective program documentation.
Guidelines for preparing a Flowchart

1. Determine the following:


a. Data to be entered
b. Information to be produced
c. The way the data will be entered
d. The point when data will be given
e. The point when information will be produced
2. There should only be one Start/Begin and Stop/End processes.
3. Concentrated on the logic of the program.
4. Choose only the important steps. No need to represent all the steps in the
flowchart.

Symbols used in Flowchart


Symbol Name Function
Terminal Represents the end and the beginning
of the program. It contains the words
“Begin” or “Start” and “End” or “Stop”
Process or Action Represents a step or an instruction
such as arithmetic operations and
comparisons. Ex. Add 5 and 7.
Input or Output Represents the step wherein
information such as letters and
numbers are entered by the user or
produced by the process. Ex. Input 3
numbers; Get A and B; Print A
Arrow or Flow Indicates the flow of direction or the
Direction Indicator next activity to be done.

Decision Denotes a decision to be made. It


involves 2 courses of action that is
answerable by either “yes/true” or
“no/false” wherein one has to be
chosen. The symbol represents the
“If…Then” and the “For…Next”
statements.
Preparation Represents the process that will
change the direction of initialization of
any value or the execution of a
variable.

Compute the area of a circle Input 3 numbers and display their product Compute the perimeter of a rectangle

Begin
Begin

𝜋 = 3.1416
radius = 5

𝐴𝑟𝑒𝑎 = 𝜋𝑟 2

Display area of
the circle

End
Data types in Python

Programming languages manipulate data which differ in form. Python recognizes the
following types of data: integers, floating-point values and strings.

Data Type Sample Value


Integers 1, -99, 198, 0
Floating-point 1.25, -0.9872, 1.00011
String ‘BSIT’, ‘Python Programming’

To determine the type of a specific data, Python has a built-in function called type(). The
argument it takes is the value. For example, in the Python Interactive mode the following
screen output shows how the function type() is used:

Arithmetic operators

Arithmetic operators are used to perform mathematical operations like addition, subtraction,
multiplication etc.
Symbol Operation Example
+ Addition 5+7
- Subtraction 24 – 14
* Multiplication 11 * 9
/ Division 13/5
% Remainder (modulo) 17 % 6
// Integer Division 14 // 3
** (Power) Exponentiation 2 ** 5

When multiple operations are involve in a problem, the order of operators will be as follows:

1st: Parenthesis ()
2nd: Exponentiation **
3rd: Multiplication *
4th: Division /
5th: Integer Division //
6th: Modulo %
7th: Addition +
8th: Subtraction -

Вам также может понравиться