Cari Blog Ini

Tampilkan postingan dengan label Introduction to Computer Science and Programming. Tampilkan semua postingan
Tampilkan postingan dengan label Introduction to Computer Science and Programming. Tampilkan semua postingan

Sabtu, 09 Januari 2016

Chapter 2 Core Element of a Program – Introduction with Python


At the end of previous chapter we have learn how to choose among variety in programming languages. And we have preferred to use Python in this course. But keep in mind, this course is not about Python. We use python as a tools to present concept that related with computational problem solving and thinking. There are many excellent online resources in the internet, that describing almost every aspect of the language. Python features that we don't need for that purpose are not presented at all.
Since its introduction by Guido von Rossum in 1990, Python has undergone many changes. For the first decade of its life, Python was a little known and little used language. That changes with the arrival of Python 2.0 in 2000. In addition to incorporating a number of important improvements to the language its self, it marked a shift in evolutionary path of the language. A large number of people began developing libraries that interfaced seamlessly with Python, and continuing support and development of the python ecosystem became a community based activity. Python 3.0 was released at the end of 2008. This version of Python cleaned up many of the inconsistencies in the design of the various releases of Python 2 (often referred as Python 2.x). However, it was not backward compatible. That means that most programs written for earlier version of Python could not be run using implementation of Python 3.0.
The backward incompatibility presents a problem for this course. In our view, Python 3.0 is clearly superior to Python 2.x. However, at the time of this writing, some important Python libraries still do not work with Python 3. We will, therefore, use Python 2.7 (into which many of the most important features of Python 3 have been "back ported") throughout this course.“ -  (Guttag, 2013)
The Basic Element of a Program
A python program, sometimes called a script, is a sequence of definitions and commands are executed by the Python interpreter in something called the shell. Typically, a new shell is created whenever execution of a program begins. In most cases, a window is associated with the shell. -  (Guttag, 2013). To have a bettter understanding about a computer program, we have to look the basic element that build a every good program. And here it is:

2.1              Statement/command

Sometimes computer didn’t have to make an operation and just do a certain task, like printing something out, or take an input from an input device or from another program. A command is an instruction given by a user telling a computer to execute something, such a run a single program or a group of linked programs. Commands are generally issued by typing them in at the command line (i.e., the all-text display mode) and then pressing the ENTER key, (Command Definition, 2004)


2.2              Object

Object are the core things that Python programs manipulate. Every object has a type that defines the kinds of things that programs can do with objects of that type. (Guttag, 2013). Object have two characteristic, there are states and behavior. For Example, aircraft can have state (position, altitude, angle, engine thrust) and behavior (rolling, pull up, climbing, full throttle). (Walrath, 1996) (Walrath, What Is an Object?, 1996)
As what we learn before that every object has a type. These kind of types can be classified by two kind of object type, that are either scalar or non-scalar. Scalar objects are indivisible, cause of each only have a single value. Countrary with that, non-scalar objects that are divisible. For example, 17 as INT is a scalar object. In the other hand 17 as STR is a non-scalar object because of it consist of 1 (STR) and 7 (STR). These are some example of object types:

2.2.1                       Object scalar

*      int is used to represent integers. Literals of type int are written in the obvious way, e.g. 3 or 10002 or -4.
*      float is used to represent real numbers. Literals of Type float are also written in the obvious way, e.g. 3.0 or 3.37 or -27.72. (It is rarely used, but it is also possible to write literals of type float using scientific notation. For example, the literal 1.6E3 stands for 1.6×103,i.e., it is the same as 1600) You might wonder why this type is not called real. Within the computer, values of type float are store in the computer as Floating Point Numbers à this representation, which is used by all modern programming languages, has many advantages. However, under some situation it causes floating point arithmatic to behave in ways that are slightly different from real arithmatic. We will disscus this in Chapter 3.
*      bool is used to represent the Boolean value True and False.
*      none is a type with a single value. We will say more about this when we get to variables.

2.2.2                       Object non scalar

*      Str
*      Array


2.3              Operator

Operator is about what computer will do with the object. As we see in Chapter 1, each instruction build from operand and operator. So, all programming languages will provide a set of operator, which generate generally same behavior. Based on the expression, these operators can divide into 4 kind of types:

2.3.1                       Aritmatic operator

This type of operator is use when we want to calculate something. When we use aritmatic operator, we will get aritmatic expression
Operator
Description
Example
+
Addition - Adds values on either side of the operator
a + b will give 30
-
Subtraction - Subtracts right hand operand from left hand operand
a - b will give -10
*
Multiplication - Multiplies values on either side of the operator
a * b will give 200
/
Division - Divides left hand operand by right hand operand
b / a will give 2
%
Modulus - Divides left hand operand by right hand operand and returns remainder
b % a will give 0
**
Exponent - Performs exponential (power) calculation on operators
a**b will give 10 to the power 20
//
Floor Division - The division of operands where the result is the quotient in which the digits after the decimal point are removed.
9//2 is equal to 4
and
 9.0//2.0 is equal to 4.0

2.3.2                       Comparison operator

When we want to know about something and how it’s value or property, we usually compare it with an object that has a known value or object. It is like when we use ‘meter (m)’ as a base unit to evaluate length of a box.
* Remember to only compare two object that has the same type.
Operator
Description
Example
==
Checks if the value of two operands are equal or not, if yes then condition becomes true.
(a == b) is not true.
!=
Checks if the value of two operands are equal or not, if values are not equal then condition becomes true.
(a != b) is true.
<> 
Checks if the value of two operands are equal or not, if values are not equal then condition becomes true.
(a <> b) is true. This is similar to != operator.
> 
Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true.
(a > b) is not true.
< 
Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true.
(a < b) is true.
>=
Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true.
(a >= b) is not true.
<=
Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true.
(a <= b) is true.



2.3.3                       Logic operator

We use logic operator when we want computer to think like us. There only two main kind of logic operator that are:
-          AND operator
-          OR operator
With this operator we can tell computer to use all the expression that allowed and provide us a conclusion.


2.3.4                       Assignment operator

After make a conclusion, usually, we want to assign a computer object to do or get something. For this, we will use assignment operator as following:
Operator
Description
Example
=
Simple assignment operator, Assigns values from right side operands to left side operand
c = a + b will assigne value of a + b into c
+=
Add AND assignment operator, It adds right operand to the left operand and assign the result to left operand
c += a is equivalent to c = c + a
-=
Subtract AND assignment operator, It subtracts right operand from the left operand and assign the result to left operand
c -= a is equivalent to c = c - a
*=
Multiply AND assignment operator, It multiplies right operand with the left operand and assign the result to left operand
c *= a is equivalent to c = c * a
/=
Divide AND assignment operator, It divides left operand with the right operand and assign the result to left operand
c /= a is equivalent to c = c / a
%=
Modulus AND assignment operator, It takes modulus using two operands and assign the result to left operand
c %= a is equivalent to c = c % a
**=
Exponent AND assignment operator, Performs exponential (power) calculation on operators and assign value to the left operand
c **= a is equivalent to c = c ** a
//=
Floor Dividion and assigns a value, Performs floor division on operators and assign value to the left operand
c //= a is equivalent to c = c // a



2.4              Expression

In simple way expression is a type of instruction that we make when we combine object (operand) with operator, which denote an object of a type. That why, every expression consists of at least one operand and can have one or more operators. For example, in the C language x+5 is an expression, as is the character string "MONKEYS." From expression we can get instruction (See section 1.2.1). An instruction can build by a single expression or from many of it. Example, when we use looping we need to expression to compare each other.
In programming, an expression is any legal combination of operand (object) and operator that have a value. Each programming language and application has its own rules for what is legal and illegal. I suggest to see again section 1.6.
Expressions are often classified by the type of operand or object that they represent. For example:
  • §  Boolean expressions: Evaluate to either TRUE or FALSE
  • §  Integer expressions: Evaluate to whole numbers, like 3 or 100
  • §  Floating-point expressions: Evaluate to real numbers, like 3.141 or -0.005
  • §  String expressions: Evaluate to character strings


2.5              Variable

Every program language has a different meaning for variable. In Python a variable just a name for an object. We use an assignment operator to combine and object with variable. An object can have one or more than one name that associated with it. Example:
Pi = 3.14159
Phi = 3.14159
Those two expression is an example of naming floating object 3.14159 with variable Pi and Phi.
In Python, variable names can contain letter, digits & special character _. Python variable name are also case-sensitive. There are a small number of reserved keywords in python that have built-in meaning and cannot be used as variable names. Those word are usually have been used as command or statement. Example in Python 2.7 are and class, del, pass, print, while, etc. (Guttag, 2013)

2.6              Comment

Purpose of a comment is to make a program easy to read (by programmer). Comment will helps programmer to produce a well form program. Not to explain the language or the semantics but to explain the thinking behind the program or to explain the algorithm. So we suggest to assume the reader understand the language.




2.7              Branching program

The kind of computation we have been looking at this far are called straight-line program. They execute one statement after another in the order in which they appear, and stop when they run out of statements. These kind of programs aren't very interesting. In fact, they are downright boring. (Guttag, 2013)
There are three way to branching a program.

2.7.1                       Conditional (If …)

The simplest statement to branching a program is to use a conditional.  A conditional statement usually has three part:

Figure 2.1 - Conditional Branching Program
a.    a test, i.e., an expression that evaluates to eather true or false;
b.    a block of code that is executed if the test evaluates to True; and
c.    an optional block of code that is executed if the test evaluates to false.
Becarefull!!! In python indentation is a semantically meaningfull.

2.7.2                       Looping or iteration

A generic iteration mechanism is depict in figure .... Like a conditional statement, it begins with a test. If the test evaluate to true, the program execute the loop body once, and then goes back to reevaluate the test. this process repeat until the test evaluates to False, after which control passes the code following the iteration statement.

Figure 2.2 - Iteration Branching Program
There are two type of statement in iteration, that are:

2.7.2.1                Countable Looping (For …)

Executes a piece of script multiple times and abbreviates the code that manages the loop variable. (tutorialspoint.com) The number of repetition determined by the program or the user.  The loop "counts" the number of times the body will be executed.  This loop is a good choice when the number of repetitions is known, or can be supplied by the user. (mathbits.com)

2.7.2.2                Conditional Looping  (While …)

Repeats a statement or group of statements while a given condition is TRUE. It tests the condition before executing the loop body. (tutorialspoint.com) If the "condition" is FALSE at the beginning of the loop, the loop is never executed.  The "condition" may be determined by the user at the keyboard.  The "condition" may be a numeric or an alphanumeric entry. (mathbits.com)  This is a good, when we focus on the “condition”, and we don’t care about the number of repetition.

2.7.3                       Steps Jumping

2.7.3.1                (Jump … / Go To…)

This is the simplest statement to jumping from one sequence of statement to another.

2.7.3.2                Function /  subroutine

We will discusses this in a chapter, later.

Bibliography


Command Definition. (2004, June 15). Retrieved August 27, 2014, from www.linfo.org: http://www.linfo.org/command.html
Expression. (n.d.). Retrieved 12 04, 2015, from www.webopedia.com: http://www.webopedia.com/TERM/E/expression.html
Guttag, J. V. (2013). Introduction to Computation and Programming Using Python (spring 2013 ed.). Cambridge, Massachusetts: The MIT Press.
Mathbits.com. (n.d.). Which LOOP should I use???? Retrieved January 9, 2016, from http://mathbits.com: http://mathbits.com/MathBits/CompSci/looping/whichloop.htm
Tutorialspoint.com. (n.d.). Python Loops. Retrieved January 9, 2016, from http://www.tutorialspoint.com: http://www.tutorialspoint.com/python/python_loops.htm
Walrath, M. C. (1996). The Java Tutorial - Object-Oriented Programming for the Internet. Addison-Wesley Pub.

Walrath, M. C. (1996, August). What Is an Object? Retrieved December 2014, from http://journals.ecs.soton.ac.uk/: http://journals.ecs.soton.ac.uk/java/tutorial/java/objects/object.html

Jumat, 01 Agustus 2014

Chapter 1 Introduction to Computer Science & Programming

                       

1.1.     Declarative vs. Imperative

1.1.1.      Declarative knowledge

                        Declarative knowledge is about “what we want to achieve”. It’s composed by statements of fact [Declarative Programming]. Simple case, when we declare set of rules about what outputs should result from which inputs. In other words, if we have A, then the result must be B. An engine will apply these rules to inputs, and give us the proper output. The focus is on what the computer should do rather than how it should do it.
                        Example:
ü  “A good health care plan improves the quality of medical care while saving money” - declarative statement -
ü  “y is the square root of x if and only if y*y = x”  - declarative statement -
ü  SQL - declarative program -

1.1.2.      Imperative knowledge

                        Imperative knowledge is about “how to achieve our goal or accomplish something”. The focus is on what steps the computer should take rather than what the computer will do (ex. C, C++, Java). Case in computer science, when we specify a series of instructions that the computer executes in sequence (do this, and then do that). We can think of it as recipe [Imperative Programming]. Example, when we specify instruction to find approximation of square root (Heron of Alexandria method)[1]:
1)      Start with a guess, g
2)      If g*g is close enough to x, then g is a good approximation of the square root of x
3)      Otherwise, create a new guess by averaging g and x/g. I.e., gnew= (gold+ x/gold)/2
4)      Using this new guess, go back to step 2
5)      Converged (well done cook)

1.2.     Program

                        A computer program is a set of instructions for a computer to perform a specific task. Programming is about controlling the computer or what computer should do. And to control the compiler we give it a program [Beginner - Introduction to Programming]. To make a computer do anything, you have to write a computer program. To write a computer program, you have to tell the computer, step by step, exactly what you want it to do. The computer then "executes" the program, following each step mechanically, to accomplish the end goal [What is a computer algorithm?].
                        When you are telling the computer what to do, you also have to choose how it's going to do it. That's where computer algorithms come in [What is a computer algorithm?]. The algorithm is the basic technique used to get the job done, or the detailed sequence of steps for carrying out some process is called algorithm [What is the differences between algorithm and program?]. Algorithm composed by a finite set of instructions to solve a specific problem or class of problems [Algorithm Analysis]. It is about how to perform computation or how computer should perform a specific task.
                        So the computer program basically is the concrete expression of an algorithm in a particular programming language [Algorithm Analysis]. In other words a computer program is a specific implementation of an algorithm, or set of algorithms designed to be used in conjunction with computer hardware (and possibly other programs) to solve a problem whereas an algorithm does not define the way it is to be implemented (though specific algorithms might by their nature suggest specific implementations) [Algorithm vs. Computer Program]. Ex, approximation program using the same Heron of Alexandria algorithm written in C++ will differed than program written in Java.
                        A computer program usually consist of:

1.2.1.      Instructions

Instruction means steps that can be executed. The instruction is the key element in the computer, as it tells (orders) the processor which action should be performed. The instructions which are to be executed are indicated in the source file and the computer goes from one instruction to the next following the instructions from top to bottom (as a file is read in sequence from top to bottom) [Programming Languages - Instructions].


Figure 1. Operator and operand(s); [Operator, 2012]
An instruction is generally comprised of two elements:
*      the operator        : the action that the processor is to carry out
*      the operand(s)    : one or more pieces of data on which the operation is performed
For a better understanding, see Figure 1.
At the lowest level language, each instruction is a sequence of 0s and 1s that describes a physical operation the computer is to perform (such as "Add") and, depending on the particular instruction type, the specification of special storage areas called registers that may contain data to be used in carrying out the instruction, or the location in computer memory of data. [Rouse, 2005]
                        In a computer's assembler language, each language statement generally corresponds to a single processor instruction. In high-level languages, a language statement generally results (after program compilation) in multiple processor instructions [Rouse, 2005]. In other words, a macro instruction is one that, during processing by the assembler program, expands to become multiple instructions (based on a previously coded macro definition) in high-level language [Rouse, 2005]. Alan Touring, the British mathematician, says that with less than 7 ‘primitive instruction’ (single processor instruction), each operate on 1 bit information, you can do anything. It means you can build any kind of complex instruction with combine some of main/single processor instruction.

1.2.2.      Control Structure / Flow of Control / Control Flow

                        When we run through a list of instructions, normally, we go through them step by step. But what if that's not the case? What if we are to press the red button when a tone is heard and the green one when not? What if we are supposed to scream when a meltdown occurs but shout when a fire starts? That's where control flow comes in to change the course of the program. Control flow is necessary because we can't expect everything to be like a set of instructions. Changes have to be made. For example, we can say, "Jump off the building if it is on fire, else continue typing your report." The statement above accomplishes something a list of instructions just can't do - change the direction.  [Beginner - Introduction to Programming]
                        Flow of control: the order in which the individual statements, instructions or function calls of an imperative or a declarative program, are executed or evaluated. [Control flow]

1.2.3.      Terminating condition:

                        Without terminating condition, computer will run to infinity.
                         

1.3.     Computer

                        The word “computer” was recorded firstly in 1613 in a book called “The yong mans gleanings” by English writer Richard Braithwait: I haue read the truest computer of Times, and the best Arithmetician that euer breathed, and he reduceth thy dayes into a short number. It referred to a person who carried out calculations, or computations, and the word continued with the same meaning until the middle of the 20th century. From the end of the 19th century the word began to take on its more familiar meaning, a machine that carries out computations. [Computer]
                        Now days, to execute the program, we can design a circuit that do exactly what the program tells. This kind of device is called computer. Based on the flexibility of the program, we can classified computer in two main type. 

1.3.1.      Fixed program computers

The first kind computing machine was fixed program computer. It is design to do specific thing. Most of this early computer were tools to solve specific mathematic problem [Guttag, 2013]. Example:
ü  A revolutionary difference engine, designed to aid in navigational calculations, by Charles Babbage, an English mechanical engineer and polymath, in early 19th century (1833).  [Computer]
ü  In 1941, built by Atanasoff and Berry Computer (ABC) to solve system of linear equation only. [Guttag, 2013]
ü  Alan Turing bombe machine, (during World War II), design strictly for breaking German Enigma Code. [Guttag, 2013]
ü  ENIAC (Electronic Numerical Integrator and Computer)
ü  (Now day) A four-function calculator only to solve basic mathematics only. (+, –, ×, ÷ ) [Guttag, 2013]

1.3.2.      Stored program computers

                        The theoretical basis for the stored-program computer was laid by Alan Turing in his 1936 paper, On Computable Numbers, with an Application to the Entscheidungsproblem [Computer]. In 1945 Turing joined the National Physical Laboratory and began work on developing the principle of electronic stored-program digital computer. His 1945 report ‘Proposed Electronic Calculator’ was the first specification for such a device. In that proposal he described a hyphothetical computing device that has come to be called a Universal Turing machine. The machine had an unbounded memory in the form of tape on which one could write zeros, ones and some primitive instruction such as moving, reading and writing to the tape. (remember, Turing machine is not the same as Universal Turing Machine).
                        The difference in stored program computer and fixed program computer rest not only in hardware but also in the programming and use of machines [Olley, 2010]. With Universal Turing Machine, Turing proposed that program can be treated and stored as data. Now, data and program are the same, and because of program can produce data, it means program can produce program.
                        It is still debated until now about the first stored program computer. And John von Neumann, a leader in continuum research at Princeton University, was offered a post-doctoral position to Turing. But Turing decide to go back to England, help his state in war with Nazi. Neumann see the idea of Universal Turing Machine and circulated his First Draft of a Report on the EDVAC in 1945  [Computer]. Neumann success to put instruction and data in the same memory. This architecture is use widely in the CPU now day (See Figure 3). Consequently, this principle can be used to describe and accomplish anything you can do with computer, by executes any legal set of instruction.
                         
                         
Figure 2. Stored program computer Architecture;
                        The first truly modern computer was The Manchester Mark 1, that built at the University of Manchester, and its first programe in 1949. It implemented ideas previously describe by John Von Newmann and Alan Turing.
                         

1.4.     Programming Language

                        From section 1.2, we see that, programming language provide a set of primitive instruction and primitive control structure. The natural language which can be directly understood by the system is a machine language. In machine language, a program is written in 1s and 0s (binary code). So, a set of instruction in binary pattern is associated with each computer. It is difficult to human like us to communicate with computer in term of binary code. Hence, writing a program with a machine language is very difficult. Moreover speed of writing, testing and debugging is very slow in machine language. Changes of making careless error are bound to be there in this language. Each type of hardware platform design, define a different type of machine language. So, machine language is tedious and time consuming. [Kamthane, 2011]
                        To cope with that, people try to create other type of languages. All other languages are said to be high level or low level according to how closely they can be said to resemble machine code.
                        These type of language are classification as follows:

1.4.2.      Assembly Language

                        Instead of using a string binary bits in a machine language, computer manufacturers started to providing something that more easy to interpreted by programmers. So, the computer manufacturers started providing mnemonics (English-like word abbreviated) that are similar to binary instruction in machine languages. The program is in alphanumeric symbols like ADD, SUB, MUL, DIV, RCL and RAL, called mnemonics. The designer chooses easy that are to be remembered by the programmer, so that the programmer can easily develop the program in assembly language. [Kamthane, 2011]
                        Here are some characteristics of the assembly languages:
-        Less time consuming for an assembler to write and then test the program, rather than in machine language.
-        Assembly languages programs are not portable, cause each type of processor has its own assembly language. For example, 8085 CPU has its own assembly language, CPUs such as 8086, 80186, 80286 have their own assembly languages.
-        Assembly language is a low-level language corresponds closely to machine code, so that a single low-level language instruction translates to a single machine-language instruction.
-        Efficient (optimum use of both computer memory and processing time) for short and simple program, cause to write a low-level program takes a substantial amount of time.
-        It is necessary to remember and understand inner workings of the processor, the registers of CPU and mnemonic instructions by the programmer.
                         

1.4.3.      High-level Language

                        As we see before, some assembly languages characteristics are disadvantages for programmer. Don’t worry, because high-level languages will overcome this problem. High-level languages are build base on procedure oriented languages. These languages are employed for easy and speedy development of a program. Examples of high-level language are COBOL, FORZTRAN, BASIC, C and C++. [Kamthane, 2011]
                        Following are some characteristics of high-level languages:
+        Less time consuming for program development than assembly language.
+        Several mnemonic instructions are needed to write in assembly language than a single line in high-level language. Thus, high language programs are shorter than the assembly language programs.
+        Testing and debugging a program is easier than in the assembly language
+        Portability of a program from one machine to other
                         

1.5.     Programming Translator

                        A program can be written in assembly language as well as in high-level language. This written program is called the source program. The source program is to be converted to the machine language, which is called an object program. All computer programs run on machine code that is executed directly on computer architecture. Machine code is not easily read or programmed directly by humans. Essentially, machine code is a long series of bits (i.e. ones and zeroes). In order to program, humans write code in a language that is then translated in to machine code.
                        Program translator translates source code of programming language into machine language-instruction code. Generally, computer programs are written in languages like COBOL, C, BASIC and ASSEMBLY LANGUAGE, which should be translated into machine language before execution. Programming language translators are classified as follows [Kamthane, 2011]:

Figure 3. Programming language translator classification;

1.5.1.      Assembler

                        The translation job is performed either manually or with a program called assembler. In hand assembly, the programmer uses the set of instructions supplied by the manufacturer. In this case, the hexadecimal code for the mnemonic instruction is searched from the code sheet. This procedure is tedious and time-consuming.
                        Alternate solution to this is the use of assemblers, the program that provides the codes of the mnemonics. An assembler translates the symbolic codes of programs of an assembly language into machine language instructions (see Figure 4a). The reasons why assembly language is efficient for small program because, with assembler, assembly language is translated in the ratio of one to one. It mean one mnemonics instructions will translate to one machine code instructions.  [Kamthane, 2011]

Figure 4a. Assembler translation process;

1.5.2.      Compiler

                        Compilers are the translators for high-level languages. Compile is a process to translate all the instructions of the program into machine codes, which can be used again and again (see Figure 4b). The source program is input to the compiler. The object code is output for the secondary storage device. The entire program will be read by the compiler first and then generates the object code. It is different from interpreter process, which we will see in the next section. High-level languages such as C, C++ and Java use compiler as the translator. The compiler also displays the list of errors and warnings for the statements violating the syntax rules of the language. Compilers also have the ability of linking subroutines of the program.  [Kamthane, 2011]

Figure 4b. Compiler translation process;

1.5.3.      Interpreter

                        Interpreters also come in the group of translators for high-level languages. Same with compiler, the interpreter source program is just like English statements. But interpreter have different in translate process. The interpreter generates object codes by reads and translate the source program line by line. Interpreter directly executes the program from its source code. Due to this, every time the source code should be inputted to the interpreter. In other words, each line is converted into the object codes. It takes very less time for execution because no intermediate object code is generated.  [Kamthane, 2011]
                        M-BASIC, Python are examples of interpreter.

Figure 4c. Interpreter translation process;

                         

1.6.     Programming Language Aspects/Elements – an English sentence analogy

                        Just like natural languages (ex, English, Chinese, Indonesian, etc), each programming languages has a set of primitive construct. The aim of this construct is to produce well form program, that has exactly only one meaning. This set of construct consist of:

1.6.1.      Syntax

                        The Syntax of a language refers to the spelling of the program, which strings/sequences of characters and symbols are well formed. For example, in English the string "ball shirt boy" is not a syntactically valid sentence, because the English grammar does not accept sentences in the form of . In Python syntax chart, the sequence of primitive 3.5 + 3.5 is syntactically well form, but the sequence 3.5 3.5 is not.
                        We discuss syntax first, because syntax errors are the most common kind of error, but it is the least dangerous kind of error. A good programming language does a complete job of detecting syntactic errors, and will not allow users to execute a program with even one syntactic error. Furthermore, in most cases the language system gives a sufficiently clear indication of the location of the error that it is obvious what need to be done to fix it. [Guttag, 2013]
                         
                         

1.6.2.      Static semantics

                        The static semantics refer to syntactically valid strings that have a meaning. For example, the English string "I are big" is of the form , which is syntactically acceptable sequence. However, it is a static semantic error, because the noun "I" is singular and the verb "are" is plural. So it doesn’t have a real meaning. In Python, the sequence 3.7/'abc' is syntactically well formed ( ), but produce a static semantic error, because dividing a number by a string of characters is not meaningful.
                        Semantic errors, is a bit more complex than syntax. Static semantic error makes program behavior become unpredictable, so it is important to do static semantic checking. Some programming languages, e.g., java, do a good job on static semantic checking before allowing a program to be executed. Others, e.g., C and Python, do relatively less static semantic checking. Python does do a considerable amount of static semantics checking while running a program. However, it does not catch all static semantic errors.  [Guttag, 2013]
                         

1.6.3.      Semantics

                        Semantics is talk about, what that meaning of the program. The special in programming language is that every well-formed program, which free of syntax and static semantics error, will only has exactly one meaning. Different with, natural languages, e.g., English, can be ambiguous. For example, the sentence "I cannot praise this student too highly" can be either flattering or damning. [Guttag, 2013]


                         
                         
                         

1.7.     Paradox of computer program

                        As we see before, program has no syntactic error and no static semantic error, it has a meaning, i.e., it has semantics and computer will do exactly what you tell it to do. This is good news. But semantic doesn’t mean that computer will do exactly as what the programmer want it to do. When a program done something other than what its creator thinks it means, bad things can happen. Now we see the paradox.
                        The following are what happen when a computer do something other than programming meaning, in order of badness:

1.7.1.      Crash

                        At the lowest level, it might crash, or in other words, it stops running and produces some sort of indication. In a properly designed computing system, when a program crashes it doesn’t damage to the overall system. Of course, some very popular computer systems don't have this nice property. Almost everyone who uses a personal computer has run a program that has managed to make it necessary to restart the whole computer. [Guttag, 2013]

1.7.2.      Never stop

                        Next level, it might keep running, and running, and running, and never stop (or called infinity loop). This situation is hard to recognize if we have no idea about how long the program is supposed to take to do its Job. [Guttag, 2013]

1.7.3.      Run to completion but produce wrong answer

                        The worst thing can happen is when the program run to completion and produce an answer that might be correct, or might not. This is very bad, cause when a program appear to be doing the right thing but isn't, disaster can follow. Example: fortunes can be lost, patients can receive fatal doses of radiation therapy, airplane can crash, etc. So it is important to programmer when they write a program, it should be written in such a way that when it doesn't work properly, it is self-evident. [Guttag, 2013]

1.8.     Why we use python in learning computer science???

                        There are many sources and reasons for us to use python as a programming learning tool. These are some conclusions of the reasons we choose Python:
·         Medioker
·         Easy to use
·         Widely use
·         Easy to debug
·         Interpreter (we can compile python but it is unusual & un-efficient)
·         Better learning curve

Bibliography

Algorithm Analysis. (n.d.). Retrieved June 12, 2013, from http://courses.cs.vt.edu/: http://courses.cs.vt.edu/cs2604/spring04/Notes/C04.AlgorithmAnalysis.pdf
                        Algorithm vs. Computer Program. (n.d.). Retrieved June 12, 2013, from http://www.coderanch.com/: http://www.coderanch.com/t/396727/java/java/Algorithm-computer-program
                        Beginner - Introduction to Programming. (n.d.). Retrieved January 31, 2013, from library.thinkquest.org: http://library.thinkquest.org/15375/b01.htm
                        Computer. (n.d.). Retrieved February 19, 2014, from wikipedia.org: http://en.wikipedia.org/wiki/Computer
                        Control flow. (n.d.). Retrieved January 8, 2013, from en.wikipedia.org: http://en.wikipedia.org/wiki/Control_flow
                        Declarative Programming. (n.d.). Retrieved January 8, 2013, from en.wikipedia.org: http://en.wikipedia.org/wiki/Declarative_programming
                        Guttag, J. V. (2013). Introduction to Computation and Programming Using Python (spring 2013 ed.). Cambridge, Massachusetts: The MIT Press.
                        Imperative Programming. (n.d.). Retrieved January 8, 2013, from en.wikipedia.org: http://en.wikipedia.org/wiki/Imperative_programming
                        Kamthane, A. (2011). PROGRAMMING IN C (2nd Edition ed.). (R. Sachdev, Ed.) India: Pearson Education India.
                        Olley, A. (2010). Existence Precedes Essence - Meaning of the Stored-Program Concept*. IHPST, University of Toronto , 10.
                        Programming Languages - Instructions. (n.d.). Retrieved June 14, 2013, from http://en.kioskea.net/: http://en.kioskea.net/contents/313-programming-languages-instructions
                        Rouse, M. (2005, September). DEFINITION - Instruction. Retrieved June 9, 2013, from http://searchcio-midmarket.techtarget.com: http://searchcio-midmarket.techtarget.com/definition/instruction
                        What is a computer algorithm? (n.d.). Retrieved June 12, 2013, from http://www.howstuffworks.com: http://www.howstuffworks.com/question717.htm
                        What is the differences between algorithm and program? (n.d.). Retrieved June 12, 2013, from http://wiki.answers.com/: http://wiki.answers.com/Q/What_is_the_differences_between_algorithm_and_program
                         




                        [1] Many believe that Heron was not Inventor of this method, and indeed there is some evidence that it was well known to the ancient Babylonians.  [Guttag, 2013]